...
Feature | Supported by the following Error Handler |
---|---|
all scopes | DefaultErrorHandler, TransactionErrorHandler, Dead Letter Channel |
onException | DefaultErrorHandler, TransactionErrorHandler, Dead Letter Channel |
onWhen | DefaultErrorHandler, TransactionErrorHandler, Dead Letter Channel |
handled | DefaultErrorHandler, TransactionErrorHandler, Dead Letter Channel |
Custom ExceptionPolicy | DefaultErrorHandler, TransactionErrorHandler, Dead Letter Channel |
useOriginalExchange useOriginalBody | |
dead letter queue | |
redeliverUntil | |
onRedelivery | |
...
Wiki Markup |
---|
{snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandleAndTransformTest.java} |
Using
...
useOriginalBody
Available as of Camel 2.0
The option useOriginalExchange useOriginalBody is used for routing the original input Exchange body instead of the current Exchange body that potential is modified and during routing.
For instance if you have this route:
...
The route listen for JMS messages and validates, transforms and handle it. During this the Exchange payload is transformed/modified. So in case something goes wrong and we want to move the message to another JMS destination, then we can add an onException. But when we move the Exchange to this destination we do not know in which state the message is in. Did the error happen in before the transformOrder or after? So to be sure we want to move the original input message we received from jms:queue:order:input
. So we can do this by enabling the useOriginalExchange useOriginalBody option as shown below:
Code Block | ||||
---|---|---|---|---|
| ||||
// will use original exchangeinput body onException(MyOrderException.class) .useOriginalExchangeuseOriginalBody().handled(true) .to("jms:queue:order:failed"); |
...