...
In Spring DSL you need to use the onRedeliveryRef attribute to refer to a spring bean id that is your custom processor:
Wiki Markup |
---|
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/DeadLetterChannelOnExceptionOnRedeliveryTest.xml} |
Wiki Markup |
---|
{snippet:id=e2|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/DeadLetterChannelOnExceptionOnRedeliveryTest.xml} |
Using onExceptionOccurred processor
Available as of Camel 2.17
Dead Letter Channel has support for onExceptionOccurred to allow custom processing of a Message just after the exception was thrown. It can be used to do some custom logging or whatnot. The difference between onRedelivery processor and onExceptionOccurred processor, is that the former is processed just before a redelivery attempt is being performed, that means it will not happen right after an exception was thrown. For example if the error handler has been configured to perform 5 seconds delay between redelivery attempts, then the redelivery processor is invoked 5 seconds later sine the exception was thrown. On the other hand the onExceptionOccurred processor is always invoked right after the exception was thrown, and also if redelivery has been disabled. Important: Any new exceptions thrown from the onExceptionOccurred processor is logged as WARN and ignored, to not override the existing exception.
In the code below we want to do some custom logging when an exception happened So we configure an onExceptionOcurred to use our custom processor:
Code Block |
---|
errorHandler(defaultErrorHandler().maximumRedeliveries(3).redeliveryDelay(5000).onExceptionOccurred(myProcessor)); |
Using onRedelivery in Spring DSL
In Spring DSL you need to use the onExceptionOccurredRef attribute to refer to a spring bean id that is your custom processor:
Code Block | ||||
---|---|---|---|---|
| ||||
<camelContext errorHandlerRef="eh" xmlns="http://camel.apache.org/schema/spring">
<errorHandler id="eh" type="DefaultErrorHandler" onExceptionOccurredRef="myProcessor">
<redeliveryPolicy maximumRedeliveries="3" redeliveryDelay="5000"/>
</errorHandler>
...
</camelContext> |
Using fine grained retry using retryWhile predicate
...