git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error/exception propagating in camel from subroutes upward?


Hello.  This should be pretty simple, but something is eluding me.  I have
my camel routing exposed via a REST endpoint for use by other services.
When a message is received from the REST endpoint, it is directed to my
Camel content based router where it is dispatched to a sub-route to fulfill
a request.

If an exception occurs in the sub-route, I want to handle it there by
wrapping it in a custom exception, and then I want to propagate it upward
to the route that contains the content based router so that I can take some
action (log it, or send it to an error queue, etc).

Currently, in the sub-route, I have it configured like:

from("vm:start")
    .doTry()
        .process(someCoolProcessor)
        .to(myResultEndpoint)
    .doCatch(Exception.class)
        .process(subRouteErrorProcessor);

When I run my app and cause an exception to be thrown, the error processor
is invoked and it wraps the exception successfully.  But I look in my logs,
and the original exception is logged in the sub-route and also in the route
that contains the content based router.  After that, only then is my
wrapped exception finally reported.

How can I prevent the exceptions from being logged by the sub-route and the
main (content based router) route, and only be logged when I specifically
want to log them?


( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03305.html on line 97
Call Stack
#TimeMemoryFunctionLocation
10.0008363576{main}( ).../msg03305.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03305.html on line 97
Call Stack
#TimeMemoryFunctionLocation
10.0008363576{main}( ).../msg03305.html:0