When working with the JMS components the correlation identifier header is called JMSCorrelationID, and they handle the correlation automatically.
Other messaging systems, such as Spring RabbitMQ also handles this automatic, and you should generally not have a need for using custom correlation IDs with these systems.
You can use your own correlation identifier to any message exchange to help correlate messages together to a single conversation (or business process). For example if you need to correlation messages when using web services.
Some EIP patterns will spin off a sub message, and in those cases, Camel will add a correlation id on the Exchange as a property with they key
Exchange.CORRELATION_ID, which links back to the source Exchange and its exchange id.
The following EIPs does this:
The following example uses a request/reply pattern in the JMS component, where correlation identifiers are automatically handled:
from("direct:start") .to(ExchangePattern.InOut, "jms:queue:foo") .to("mock:result");
And with XML DSL:
<route> <from uri="direct:start"/> <to pattern="InOut" uri="jms:queue:foo"/> <to uri="mock:result"/> </route>