Which endpoint failed - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

When Camel routes messages it will decorate the Exchange with a property that contains the last endpoint Camel send the Exchange to:

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 it's 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:

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 Camel Component: Bean processing instead. So be aware that this is a hint that helps pinpoint errors.

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 .

Starting with Camel 2.11, the route that failed can also be determined by using the following:

String failedRouteId = exchange.getProperty(Exchange.FAILURE_ROUTE_ID, 
   String.class);