Put a splitter in the route to split up the list and forward the split
exchanges to route b. In route b handle the items and if one fails you put
it in the DLQ, and ignore it. Another route can aggregate to do reporting
if it wants.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Tue, Dec 10, 2013 at 9:39 AM, Stephan Burkard <[email protected]> wrote:

> Well, if I don't misunderstand the situation, you could just use try/catch
> inside "createSimpleProduct" method to skip the bad items.
>
> Regards
> Stephan
>
>
> On Thu, Dec 5, 2013 at 12:33 PM, [email protected] <
> [email protected]> wrote:
>
> > 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