You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ishada <ab...@gmail.com> on 2015/11/19 00:08:09 UTC
Exception Handling in camel onWhen
I am using Camel in the integration Project to connect it to the Http
Endpoint. Now I am trying to implement a scenario such as when ever there is
an exception while connecting to the HTTP endpoint , I should use the status
code to decide whether to try re-delivery or else continue the route. Here
is how am I trying to implement
onException(HttpOperationFailedException.class)
.retryAttemptedLogLevel(LoggingLevel.DEBUG)
.onWhen(new Predicate() {
@Override
public boolean matches(Exchange exchange) {
HttpOperationFailedException e = exchange.getProperty(
Exchange.EXCEPTION_CAUGHT,
HttpOperationFailedException.class);
if (e.getStatusCode() == 400)
return true;
return false;
}
}).continued(true).maximumRedeliveries(2);
The problem is when ever the Predicate return false the route is stop. what
I am trying to achieve is to continue the route.
--
View this message in context: http://camel.465427.n5.nabble.com/Exception-Handling-in-camel-onWhen-tp5774076.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Exception Handling in camel onWhen
Posted by Claus Ibsen <cl...@gmail.com>.
You can use a predicate in the continued(true) so you use the code to
decide whether to continue or not.
On Thu, Nov 19, 2015 at 12:08 AM, Ishada <ab...@gmail.com> wrote:
>
> I am using Camel in the integration Project to connect it to the Http
> Endpoint. Now I am trying to implement a scenario such as when ever there is
> an exception while connecting to the HTTP endpoint , I should use the status
> code to decide whether to try re-delivery or else continue the route. Here
> is how am I trying to implement
>
> onException(HttpOperationFailedException.class)
> .retryAttemptedLogLevel(LoggingLevel.DEBUG)
> .onWhen(new Predicate() {
> @Override
> public boolean matches(Exchange exchange) {
>
> HttpOperationFailedException e = exchange.getProperty(
> Exchange.EXCEPTION_CAUGHT,
> HttpOperationFailedException.class);
>
> if (e.getStatusCode() == 400)
> return true;
> return false;
> }
> }).continued(true).maximumRedeliveries(2);
>
> The problem is when ever the Predicate return false the route is stop. what
> I am trying to achieve is to continue the route.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-Handling-in-camel-onWhen-tp5774076.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