You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by fbarbat <fb...@gmail.com> on 2013/09/12 16:29:18 UTC

DefaultErrorHandler and "nested" routes

Hi,

I have these routes:

from("direct:a").routeId("1")
.onException(Exception.class).handled(true).to("direct:d").end()
.to("direct:b").to("direct:c");

from("direct:b").routeId("2").process(new ThrowingExceptionProcessor());
from("direct:c").routeId("3").process(new OkProcessor());

from("direct:d").routeId("4").process(new ExceptionProcessor());

Let's suppose a message comes to route 1. If ThrowingExceptionProcessor
throws an exception I would expect that the exception would be handled by
the onException clause. However, it looks like the exception is propagated
directly to the consumer ("direct:a"). How can I force the exceptions thrown
inside "child routes" to be managed by the onException clause?

Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/DefaultErrorHandler-and-nested-routes-tp5739261.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: DefaultErrorHandler and "nested" routes

Posted by Christian Müller <ch...@gmail.com>.
from("direct:b").routeId("2")
  .errorHandler(noErrorHandler())
  .process(new ThrowingExceptionProcessor());

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Thu, Sep 12, 2013 at 4:29 PM, fbarbat <fb...@gmail.com> wrote:

> Hi,
>
> I have these routes:
>
> from("direct:a").routeId("1")
> .onException(Exception.class).handled(true).to("direct:d").end()
> .to("direct:b").to("direct:c");
>
> from("direct:b").routeId("2").process(new ThrowingExceptionProcessor());
> from("direct:c").routeId("3").process(new OkProcessor());
>
> from("direct:d").routeId("4").process(new ExceptionProcessor());
>
> Let's suppose a message comes to route 1. If ThrowingExceptionProcessor
> throws an exception I would expect that the exception would be handled by
> the onException clause. However, it looks like the exception is propagated
> directly to the consumer ("direct:a"). How can I force the exceptions
> thrown
> inside "child routes" to be managed by the onException clause?
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/DefaultErrorHandler-and-nested-routes-tp5739261.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: DefaultErrorHandler and "nested" routes

Posted by Claus Ibsen <cl...@gmail.com>.
You can also turn off error handler on your sub routers, by
configuring them to use noErrorHandler.

Or use the doTry .. doCatch in the parent route when calling sub
routes to force no error handling in sub routes.


On Thu, Sep 12, 2013 at 8:53 PM, fbarbat <fb...@gmail.com> wrote:
> Hi,
>
> I cannot use a global onException because different actions have to be taken
> on different routes to handle the exceptions. Besides, I'm handling
> NoSuchElementException which is a very generic exception and handling should
> be restricted to a specific route.
>
> Just to be sure, OnException never handles exceptions from "inner" routes,
> right?
>
> Anyway, I'll think how to structure routes in a different way so I can
> handle this case.
>
> Thanks!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/DefaultErrorHandler-and-nested-routes-tp5739261p5739278.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: DefaultErrorHandler and "nested" routes

Posted by fbarbat <fb...@gmail.com>.
Hi,

I cannot use a global onException because different actions have to be taken
on different routes to handle the exceptions. Besides, I'm handling
NoSuchElementException which is a very generic exception and handling should
be restricted to a specific route.

Just to be sure, OnException never handles exceptions from "inner" routes,
right? 

Anyway, I'll think how to structure routes in a different way so I can
handle this case.

Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/DefaultErrorHandler-and-nested-routes-tp5739261p5739278.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: DefaultErrorHandler and "nested" routes

Posted by Claus Ibsen <cl...@gmail.com>.
Move it outside the route so its context scoped onException instead.


On Thu, Sep 12, 2013 at 4:29 PM, fbarbat <fb...@gmail.com> wrote:
> Hi,
>
> I have these routes:
>
> from("direct:a").routeId("1")
> .onException(Exception.class).handled(true).to("direct:d").end()
> .to("direct:b").to("direct:c");
>
> from("direct:b").routeId("2").process(new ThrowingExceptionProcessor());
> from("direct:c").routeId("3").process(new OkProcessor());
>
> from("direct:d").routeId("4").process(new ExceptionProcessor());
>
> Let's suppose a message comes to route 1. If ThrowingExceptionProcessor
> throws an exception I would expect that the exception would be handled by
> the onException clause. However, it looks like the exception is propagated
> directly to the consumer ("direct:a"). How can I force the exceptions thrown
> inside "child routes" to be managed by the onException clause?
>
> Thanks.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/DefaultErrorHandler-and-nested-routes-tp5739261.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen