Exchange Pattern
There are two Message Exchange Patterns (MEP) you can use in messaging.
From the Enterprise Integration Patterns they are:
-
Event Message (or one-way)
In Camel, we have an
org.apache.camel.ExchangePattern
enumeration which can be configured on the exchangePattern property on
the Message Exchange indicating if a message
exchange is a one way Event Message (InOnly) or
a Request Reply message exchange (InOut).
How Exchange Pattern Works
The exchange pattern is a contract between the route and the component endpoint.
It tells the component whether the caller expects a reply (InOut) or not (InOnly).
The exchange pattern does not affect how EIPs and processors work within the route.
Processors such as setBody, transform, process, and bean always operate on the
current message body regardless of the exchange pattern.
The pattern only matters when the exchange reaches a producer endpoint (i.e., a to step)
that acts on it.
Most components have a fixed exchange pattern — for example,
HTTP is always InOut (request/reply) and
Kafka is always InOnly (fire-and-forget).
For these components the exchange pattern setting has no effect.
The exchange pattern is historically used by a limited set of components that support both
InOnly and InOut, such as JMS,
SEDA, and AMQP.
These components use the pattern to decide between fire-and-forget and request/reply messaging.
For example, with JMS InOnly sends a message to a queue without waiting for a reply,
while InOut sets up a temporary reply queue (via JMSReplyTo) and waits for a response.
For example to override the default pattern on a JMS
endpoint you could use the exchangePattern parameter in the Endpoint URI
as shown:
jms:myQueue?exchangePattern=InOut