Camel supports an equivalent to Java's try…catch…finally exception handling that provides the finest grained error handling within Camel, in that you can specify exception handling specific to one or more route processing steps. Camel provides a doTry…doCatch…doFinally set of declarations that mirror Java's try…catch error handling.
This recipe will show you how to use the doTry
DSL statement.
The Java code for this recipe is located in the org.camelcookbook.error.dotry
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with dotry
.
In the XML DSL, there are two mandatory steps and one optional steps needed for using doTry
, which are as follows:
Within a route, define a
doTry
element for wrapping one or more processing steps for which you want to provide specific error handling. This must be after thefrom
element asdoTry
cannot handle errors thrown from the consuming endpoint...