Marking exceptions as handled
The default behavior for Camel is to call your exception (or error) handler, and rethrow the exception to the caller. This recipe will show how to mark that exception as handled, which tells Camel that it should not consider this to be an error and nothing further needs to be done, that is, do not rethrow that particular exception to the consuming endpoint.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.error.exception
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with exception
.
How to do it...
Within the onException
DSL statement, specify a handled
statement with a predicate that will indicate if the exception has been handled (predicate evaluates to true
) or if it is not handled (predicate evaluates to false
, so exception should be re-thrown).
In the XML DSL, define an onException
element within either the camelContext
or route
element. Within the onException
element include one...