Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the sample above we have two onException's defined. The first has an onWhen expression attached to only trigger if the message has a header with the key user that is not null. If so this clause is selected and is handling the thrown exception. The 2nd clause is a for coarse gained selection to select the same exception being thrown but when the expression is evaluated to false. Notice: this is not required, if the 2nd clause is omitted, then the default error handler will kick in.

Using onRedelivery processor

Available as of Camel 2.0

Dead Letter Channel has support for onRedelivery to allow custom processing of a Message before its being redelivered. It can be used to add some customer header or whatnot. In Camel 2.0 we have added this feature to Exception Clause as well, so you can use per exception scoped on redelivery. Camel will fallback to use the one defined on Dead Letter Channel if any, if none exists on the Exception Clause. See Dead Letter Channel for more details on onRedelivery.

In the code below we want to do some custom code before redelivering any IOException. So we configure an onException for the IOException and set the onRedelivery to use our custom processor:

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelOnExceptionOnRedeliveryTest.java}

And in our custom processor we set a special timeout header to the message. You can of course do anything what you like in your code.

Wiki Markup
{snippet:id=e4|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelOnExceptionOnRedeliveryTest.java}

Using fine grained retry using retryUntil predicate

...