I'm fairly new to apache camel, but I want to build an exception handling using onException
.
Since I want to catch the exception and provide a response, but also want to log the error to an external system, I'd like to have 2 beans to handle the exception.
Currrently I'm having
onException(Exception.class)
.handled(true)
.bean(MyExceptionHandler.class);
I'd like to have
onException(Exception.class)
.handled(true)
.bean(MyExceptionHandler.class)
.bean(MyExceptionLogger.class)
However, the MyExceptionLogger
is never called, since the handling seems to be done after the MyExceptionHandler
.
What can I do about this? Apart from putting the logging logic into the MyExceptionHandler
because I'd like to seperate it.
No idea what you are doing inside MyExceptionHandler.class
but this should simply work. You can add as much steps to the Exception handler as you like. It is basically a normal Camel route.
However, I can imagine that when an Exception occurs in MyExceptionHandler.class
that the message simply "disappears" without touching MyExceptionLogger.class
.