Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: onException does not redeliver by default

...

The default error handler used in Camel is the Dead Letter Channel which supports attempting to redeliver the message exchange a number of times before sending it to a dead letter endpoint.
See Dead Letter Channel for further information about redeliver and which redeliver options exists.

Info
titleNo redelivery is default for onException

By default any Exception Clause will not redeliver! (as it sets the maximumRedeliveries option to 0).

Sometimes you want to configure the redelivery policy on a per exception type basis. By default in the first top examples, if a ValidationException occurs then the message will not be redelivered; however if some other exception occurs (such as a JDBC deadlock or remote method invocationIOException or whatelse) the route will be retried according to the settings from the Dead Letter Channel.

However if you want to customize any methods on the RedeliveryPolicy object, you can do this via the fluent API:. So lets retry in case of ValidationException up till two times.

Code Blockcode
onException(MyExceptionValidationException.class).
  maximumRedeliveries(2);

...

Code Block
xml
xml
<onException>
   <exception>com.mycompany.MyException<ValidationException</exception>
   <redeliveryPolicy maximumRedeliveries="2"/>
</onException>

You can customize any of the [RedeliveryPolicy|http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/processor/RedeliveryPolicy.html] so we can for instance set a different delay of 5000 millis:
{code:xml}
<onException>
   <exception>com.mycompany.ValidationException</exception>
   <redeliveryPolicy maximumRedeliveries="2" delay="5000"/>
</onException>

Reusing ReliveryPolicy

Available as of Camel 1.5.1 or later
You can reference a RedeliveryPolicy so you can reuse existing configurations and use standard spring bean style configuration that supports property placeholders.

...