RabbitMQ & AMQP (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How do you implement RPC (Remote Procedure Call) patterns in RabbitMQ?
senior LevelSystem DesignRabbitMQMicroservices
In Simple Words: AMQP supports two-way request-response patterns over asynchronous queues using message headers:
- The Client generates a unique
correlation_id(e.g. UUID) and creates an exclusive callback reply queue. - The Client publishes the request with:
reply_to: callback_queue_namecorrelation_id: "corr_492"
- The Server processes the request and publishes the response directly to the queue specified in
reply_to, preserving the samecorrelation_id. - The Client listens on its callback queue, matches the
correlation_id, and resolves the promise.