You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shabin5785 <sh...@outlook.com> on 2016/10/18 08:38:23 UTC
Apace Camel : Custom Redelivery Policy
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.
Re: Apace Camel : Custom Redelivery Policy
Posted by Shabin5785 <sh...@outlook.com>.
Thanks. Using when to check condition for re-delivery policy works :)
--
View this message in context: http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891p5788944.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apace Camel : Custom Redelivery Policy
Posted by Claus Ibsen <cl...@gmail.com>.
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 <sh...@outlook.com> 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
Re: Apace Camel : Custom Redelivery Policy
Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
Is there a specific exception you can catch when the connection fails? If so, you could use onException to handle that case.
onException(ConnectException.class).maximumRedeliveries(3).handled(true).to(jms:dlc)
Something like the above should handle #1.
> On Oct 18, 2016, at 2:38 AM, Shabin5785 <sh...@outlook.com> 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.