Request-reply over a queue
reply-to and correlation-id turn two one-way messages into a request-response call.
Open this lesson in the learning hubKey points
- The
reply-toproperty names the queue for the answer andcorrelation-idpairs them up. - Direct reply-to consumes from
amq.rabbitmq.reply-to, a pseudo-queue you never declare or delete. - Declaring a fresh exclusive reply queue per call is slow, so one reply queue per client is the usual fix.
- The caller must time out itself - a broker hop hides the TCP failure a direct call would surface.
RabbitTemplate.convertSendAndReceiveuses direct reply-to and a 5 second reply timeout.- Two extra hops buy nothing if the caller just blocks, so consider calling the service directly instead.
RPC over AMQP is two messages joined by a correlation id - the timeout is entirely yours to enforce.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the RabbitMQ Course course, and every lesson in it is listed on the RabbitMQ Course contents page.