Request/Reply patterns
One-way communication offers great parallelism and efficiency, but it cannot solve every integration need. Sometimes a request/reply pattern is the better fit. When only an asynchronous one-way channel is available, we can still build abstractions to enable request/reply messaging. That is what we will explore next.
Correlation Identifier
The first Request/Reply pattern that we are going to learn is called Correlation Identifier, and it represents the basic block for building a request/reply abstraction on top of a one-way channel.
The pattern involves marking each request with an identifier, which is then attached to the response by the receiver; this way, the sender of the request can correlate the two messages and return the response to the right handler. This elegantly solves the problem in the context of a one-way asynchronous channel, where messages can travel in any direction at any time. Let’s look at the example in the following diagram...