We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Messaging Event Systems
Free preview: the first 2 parts of this 6-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Messaging Event Systems
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
You have seen request-response. The client calls the server directly and waits. Simple, but tightly coupled. Both sides must be available at the same time, and the client must know the server's address.
Now imagine you want the same semantics (send a request, get a response) but through a . The client sends the request to a queue, a server picks it up, processes it, and sends the reply to another queue. The client listens on the reply queue for its answer.
Why would you do this? Because the queue gives you everything direct calls lack:
This is the request-reply pattern (sometimes called RPC over messaging), and it is used by RabbitMQ, Azure Service Bus, NATS, and any system that needs request-response semantics with queue-level resilience.
The tricky part: when the reply arrives on the reply queue, how does the client know which request it belongs to? If the client sent 50 requests concurrently, it needs to match each reply to its original request.
The answer is a correlation ID. The client generates a unique ID for each request and attaches it to the message. The server copies the correlation ID into the reply. The client matches replies to requests by ID.
Request message:
correlationId: "req-abc-123"
replyTo: "reply-queue-client-1"
body: { action: "getPrice", productId: "SKU-456" }
Reply message:
correlationId: "req-abc-123"
body: { price: 29.99, currency: "USD" }
The replyTo field tells the server where to send the response. This can be:
RabbitMQ's RPC tutorial uses the exclusive queue approach: each client creates an auto-delete reply queue on connect and destroys it on disconnect. Azure Service Bus supports session-based reply queues where the session ID acts as the correlation mechanism.
It is easy and good
“It is really nice and good Please join the course”