Hi All,

I've got a question about error handling. Here is my scenario...

I have a route which calls a bean..

from(...JPA...)
.errorHandler(deadLetterChannel("log:dead")
.maximumRedeliveries(5)
.retryAttemptedLogLevel(LoggingLevel.ERROR))
.to("bean:serviceBean?method=login")
.to("bean:serviceBean?method=createSimpleProduct")


Where my service bean looks like this...

        public void login(Exchange exchange) {
                SharedModel model = new SharedModel();
                exchange.getOut().setHeaders(exchange.getIn().getHeaders());
                exchange.getOut().setBody(model);
        }

        public void createSimpleProduct(Exchange exchange) {
                ImportPayloadEntity importPayloadEntity =
(ImportPayloadEntity)exchange.getIn().getHeader(CamelConstants.HEADER_KEY_IMPORT_PAYLOAD);
                Collection<ItemEntity> itemEntities = 
importPayloadEntity.getItems();
                for (ItemEntity item : itemEntities) {          
                     
                      SharedModel model = ((SharedModel)
(exchange.getIn().getBody()));
                      ....
                      call soap call for each item in loop and use
attributes from SharedModel in calls
                }
}


So what happens currently is that when there is an error in create simple
product, because the model is being used as the message, the route will fail
(after unsuccessful retries) when it comes across the first bad item.

I have been wondering how could I change this so that it sidelines only the
bad item and keep going through the rest?

I had some tries at changing my route to use a Splitter to split my route
into individual item messages (which might work nicely) but then I realized
that I would lose my sharedModel as the message body which i need that to
make the service calls. 

What is the best design pattern for this situation?

much appreciated
 



--
View this message in context: 
http://camel.465427.n5.nabble.com/error-handling-design-pattern-advice-tp5744364.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to