osdir.com

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

dealing with exceptions in onExceptions definitions


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