You can use onWhen on an onException where the onWhen is a predicate to determine if that onException should trigger or not.
Some details here http://camel.apache.org/exception-clause.html If you have a copy of Camel in Action book this is covered much more in details in that book, as it has a full chapter on error handling. On Tue, Oct 18, 2016 at 10:38 AM, Shabin5785 <[email protected]> wrote: > I have a route that calls an external rest service. I have configured my > error handler as shown below. > > errorHandler(deadLetterChannel("jms:dlc").maximumRedeliveries(3)); > > What i want to do: > > 1) If connection to external api fails, i want to retry 3 times and then > send to deadLetterChannel > 2) If api call is fine, i want to check the status code, log the response > and then send the message to deadLetterChannel. > For that i set throwExceptionOnFailure to false. > > In my route i have a bean as the last endpoint. This bean receives the > response from the external end point and checks for the status. > > void process(Exchange exchange){ > //check http status code > //if not success > exchange.setProperty(Exchange.ROUTE_STOP,true); > //sendToDeadLetterQueue; > } > > > My problem is that redelivery happens even when i am able to connect to API. > I expect the redelivery to happen on error. I am handling the response from > API and also stopping the exchange. So i expect my Bean to log the response > from API, send to deadLetterQueue(I have a route for that) and stop. But > redelivery happens 3 times evand so en when API call is successful and so > deadletterchannel route is invoked 3 times > > Can i stop the redelivery from my bean? > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
