Search code examples
javaactivemq-classicmessage-queueproducer-consumer

How to use multiple producers and one consumer with activeMQ?


So i am trying to use ActiveMQ within my java project (I never used anything like this before but I've read about how it works).

The application runs on 5 different nodes and on each of them are created the messages that should be send into the same queue.

Here is how I think it should work : I have a class which creates these messages; these messages are created in any of those nodes; so this class works as a thread and should be "the producer", sending every message to the same queue.(therefore I have multiple producers) The consumer class runs always on the same node.

Would this approach work for me? Would the queue be thread safe?


Solution

  • Yes, your approach should work without any problem. All message brokers support multiple concurrent producers sending messages to the same queue. There should be no thread safety concerns.