Hi Eduard,
I think the behavior for the "handled" case is consistent with the
documentation for the exception clause
(https://camel.apache.org/manual/exception-clause.html):
"If handled is true, then the thrown exception will be handled and Camel
will not continue routing in the original route, but break out....
If continued is true, then Camel will catch the exception and in fact
just ignore it and continue routing in the original route."
But it would seem that if you use "continued", the onCompletion handler
*should* be run, contrary to what you experience.
Karen
On 08/08/2022 14:23, Eduard Gomoliako wrote:
Hello, dear users of Camel,
I encountered an issue when I tried to configure an error ignoring route with
onCompletion.
I have a route with onCompletion part that I expect to get executed in all the
possible cases (except route stopped). This onCompletion part works well with
and without exceptions being thrown.
When exceptions are thrown, Camel executes its default strategy which includes
errors appearing in the logs, redelivering, etc.
There is an exception of a certain kind that I don’t want to be handled: to
appear in the logs, to be attempted to be redelivered.
I added onException part to the route with onWhen that determines if an error
should be ignored and the exception is marked as handled. The point was to
avoid such errors being logged and propagated for handling.
The behavior I witnessed in this case, suggests that once a route gets an
exception marked as handled the corresponding message doesn’t get handled in
the onCompletion block. I witness the same behavior when I use `continued`
instead of `handled`.
I wonder if this behavior is aligned with the design or if it’s a bug.
As a user, I’d expect the steps in the `onCompletion` clause to be executed no
matter what unless the route is stopped.
I’d appreciate you sharing your thoughts here.
Best regards,
Ed