Fine-grained error handling using doTry…doCatch

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.

Getting ready

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.

How to do it...

In the XML DSL, there are two mandatory steps and one optional steps needed for using doTry, which ...

Get Apache Camel Developer's Cookbook 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.