...
And a boolean flag whether it is being redelivered or not (first attempt)
In Camel 1.x: The header org.apache.camel.Redelivered contains a boolean if the message is redelivered or not.
In Camel 2.0: The header CamelRedelivered contains a boolean if the message is redelivered or not.
Which endpoint failed
Available as of Camel 2.1
When Camel routes messages it will decorate the Exchange with a property that contains the last endpoint Camel send the Exchange to:
Code Block |
---|
String lastEndpointUri = exchange.getProperty(Exchange.TO_ENDPOINT, String.class);
|
The Exchange.TO_ENDPOINT
have the constant value CamelToEndpoint
.
This information is updated when Camel sends a message to any endpoint. So if it exists its the last endpoint which Camel send the Exchange to.
When for example processing the Exchange at a given Endpoint and the message is to be moved into the dead letter queue, then Camel also decorates the Exchange with another property that contains that last endpoint:
Code Block |
---|
String failedEndpointUri = exchange.getProperty(Exchange.FAILURE_ENDPOINT, String.class);
|
The Exchange.FAILURE_ENDPOINT
have the constant value CamelFailureEndpoint
.
This allows for example you to fetch this information in your dead letter queue and use that for error reporting.
This is useable if the Camel route is a bit dynamic such as the dynamic Recipient List so you know which endpoints failed.
Notice: These information is kept on the Exchange even if the message was successfully processed by a given endpoint, and then later fails for example in a local Bean processing instead. So beware that this is a hint that helps pinpoint errors.
Code Block |
---|
from("activemq:queue:foo")
.to("http://someserver/somepath")
.beanRef("foo");
|
Now suppose the route above and a failure happens in the foo
bean. Then the Exchange.TO_ENDPOINT
and Exchange.FAILURE_ENDPOINT
will still contain the value of http://someserver/somepath
.
Samples
The following example shows how to configure the Dead Letter Channel configuration using the DSL
...