Correlation Identifier
Camel supports the Correlation Identifier from the EIP patterns by getting or setting a header on the Message.
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.
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
Example
The following example uses a request/reply pattern in the JMS component, where correlation identifiers are automatically handled:
-
Java
-
XML
-
YAML
from("direct:start")
.to(ExchangePattern.InOut, "jms:queue:foo")
.to("mock:result");
<route>
<from uri="direct:start"/>
<to pattern="InOut" uri="jms:queue:foo"/>
<to uri="mock:result"/>
</route>
- from:
uri: direct:start
steps:
- to:
uri: jms:queue:foo
pattern: InOut
- to:
uri: mock:result