Search code examples
javaspringspring-bootrabbitmqspring-rabbit

Asynchronous request-reply with Spring Boot and RabbitMQ


We want to implement the following scenario:

  1. A producer service sends some input params to another service asking for the details based on these params.
  2. A producer wants to specify the queue where it will be listening for the reply.
  3. Moreover, a producer wants to provide some metadata so that it can correlate the params it sent with a result it got.

Please advice how to do this properly.


Solution

  • See the AsyncRabbitTemplate.

    It uses the correlationId and replyTo properties to convey that information to the service that handles the request.