Correlation Identifier

Camel supports the Correlation Identifier from the EIP patterns by getting or setting a header on the Message.

When working with the ActiveMQ or JMS components the correlation identifier header is called JMSCorrelationID, and they handle the correlation automatically.

Other messaging systems, such as 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.

The use of a correlation identifier is key to working with Distributed Tracing and be useful when using Tracer messages to log, or testing with simulation or canned data such as with the Mock testing framework.

EIPs using correlation identifiers

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:

    .to(ExchangePattern.InOut, "jms:queue:foo")

And with XML DSL:

    <from uri="direct:start"/>
    <to pattern="InOut" uri="jms:queue:foo"/>
    <to uri="mock:result"/>