Attaching a Message History to the message will provide a list of all applications that the message passed through since its origination.
When Camel sends a message to an endpoint that endpoint information is stored on the Exchange as a property with the key
This property contains the last known endpoint the Exchange was sent to (it will be overridden when sending to new endpoint). Alternatively you can trace messages being sent using interceptors or the Event Notifier.
Easier Message History
Available as of Camel 2.12
Message History is enabled by default from Camel 2.12. During routing Camel captures how the Exchange is routed, as a
org.apache.camel.MessageHistory entity that is stored on the Exchange. On the
org.apache.camel.MessageHistory there is information abut the route id, processor id, timestamp, and elapsed time it took to process the Exchange by the processor.
The information can be reached from Java code with:
Enabling or disabling message history
The Message History can be enabled or disabled per
CamelContext or per route. For example you can turn it off with
Or from XML DSL with
You can also do this per route. Then a route level configuration overrides the
CamelContext level configuration.
Route stack-trace in exceptions logged by error handler
If Message History is enabled, then Camel will leverage this information, when the Error Handler logs exhausted exceptions. Then in addition to the caused exception with its stacktrace, you can see the message history; you may think this as a "route stacktrace". And example is provided below:
You can turn off logging message history from the Error Handler using
Using This Pattern
If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out.