Search code examples
rabbitmqspring-amqpspring-rabbit

Spring AMQP: AsyncRabbitTemplate multiple instances


Is it possible to use the AsyncRabbitTemplate in a multi instance environment?

In my case, the instance that sends the request might not be the one handling the response. AsyncRabbitTemplate keeps track of sent messages in a ConcurrentHashMap so I'm wondering if the consumer only consumes messages that it has a reference to.

If this is an entirely wrong approach, can you point me in the right direction?


Solution

  • You can have multiple instances but the replies have to go back to the sending instance (they can't use the same reply queue).

    If a late (or unknown) reply is received, it is logged and discarded.