Discussion:
dealing with exceptions in onExceptions definitions
Dennis Holunder
2018-11-13 09:16:20 UTC
Permalink
Hello,

I have two onException definitions which catch exceptions and send
them to direct:logerrors endpoint. The second exception might throw an
exception which should be caught and handled by the first one. But
this doesn't work. The FatalFallbackErrorHandler kicks in and as the
result the exception is not logged by direct:logerrors, as I wish. Any
ideas how to safely implement this?

from(direct:start)
.onException(UpdateException.class) //retries and logs the error
.handled(true)
.maximumRedeliveries(5)
.redeliveryDelay(1_000L)
.to(direct:logerrors)
.end()
.onException(IgnoredException.class) //saves the POJO and
logs the error
.handled(true)
.process().body(Pojo.class, processor::update) //
throws UpdateException
.to(direct:logerrors)
.end()

Regards,
Dan
Claus Ibsen
2018-12-03 18:04:59 UTC
Permalink
Hi

This is by design, to avoid circular onException to trigger in endless.
So try to design your error handling in a more safe manner
Post by Dennis Holunder
Hello,
I have two onException definitions which catch exceptions and send
them to direct:logerrors endpoint. The second exception might throw an
exception which should be caught and handled by the first one. But
this doesn't work. The FatalFallbackErrorHandler kicks in and as the
result the exception is not logged by direct:logerrors, as I wish. Any
ideas how to safely implement this?
from(direct:start)
.onException(UpdateException.class) //retries and logs the error
.handled(true)
.maximumRedeliveries(5)
.redeliveryDelay(1_000L)
.to(direct:logerrors)
.end()
.onException(IgnoredException.class) //saves the POJO and
logs the error
.handled(true)
.process().body(Pojo.class, processor::update) //
throws UpdateException
.to(direct:logerrors)
.end()
Regards,
Dan
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Loading...