Return Address
Learn how to use return address to manage multiple queues or requestors in an application.
The Correlation Identifier is the fundamental pattern for creating a request/reply communication on top of a one-way channel. However, it’s not enough when our messaging architecture has more than one channel or queue, or when there can be potentially more than one requestor. In these situations, in addition to a correlation ID, we also need to know the return address, a piece of information that allows the replier to send the response back to the original sender of the request.
Implementing the Return Address pattern in AMQP
In the context of an AMQP-based architecture, the return address is the queue where the requestor is listening for incoming replies. Because the response is meant to be received by only one requestor, it’s important that the queue is private and not shared across different consumers. From these properties, we can infer that we’re going to need a transient queue scoped to the connection of the requestor and that the replier has to establish a point-to-point communication with the return queue to be able to deliver its responses.
The following illustration gives us an example of this scenario.
The illustration above shows us how each requestor has its own private queue, specifically intended to handle the replies to their requests. All requests are instead sent to a single queue, which is then consumed by the replier. The replier will route the replies to the correct response queue thanks to the return address ...