0

I have a couple of queues and I need to do the following with ONE of them: A producer should send a message to this queue, but ALL consumers should receive it. So, if I have 5 spring listeners on this queue, each of them should receive the message, but not the producer. I do that because I have a tomcat cluster and rabbitmq asynchronous messages, and if I get response from the worker, I don't know how to dispatch it to the correct tomcat node. So I decided to broadcast all worker replies to all tomcat nodes. Each tomcat cluster node listens the same output queue. Then, if it's a correct tomcat instance, it will be processed, all other copies will be lost, and it's ok. How to implement it? How make consumers on tomcat's end to receive the same message the same time?

avalon
  • 2,231
  • 3
  • 24
  • 49
  • This is an **XY** problem. You should use a `direct` exchange and have each node subscribe with a different routing key. Then simply set the `reply-to` header when you send the message and use that to determine the routing key for the response. Using a `fanout` exchange and dropping messages is what you are proposing - that's wasteful. – Boris the Spider Dec 18 '15 at 08:44
  • P.S. messages are **sent** to _exchanges_. Messages are **received** from _queues_. Queues **subscribe** to exchanges (exchanges also subscribe to exchanges). – Boris the Spider Dec 18 '15 at 08:46

1 Answers1

0

Ok, found the solution here: RabbitMQ / AMQP: single queue, multiple consumers for same message? It's impossible to do in rabbitmq, need to create a couple of queues for each consumer.

Community
  • 1
  • 1
avalon
  • 2,231
  • 3
  • 24
  • 49