Camel error handlers

As we saw, Camel stores the exceptions in the exchange using the setException(Throwable cause) method.

Camel provides ready-to-use error handlers, depending of the mechanism that you have to implement. These error handlers will only react to the exceptions set in the exchange. By default, the error handlers won't react if an irrecoverable error has been set as the fault message. We will see, further in the chapter, that Camel provides an option to handle irrecoverable errors.

In order to react, the error handler lives on the route channels. Actually, an error handler is an interceptor (on the channel), that analyzes the exchange, and verifies that the exception attribute of the exchange is not null.

If the exception is not null, ...

Get Mastering Apache Camel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.