p.magalhaes
p.magalhaes

Reputation: 8374

Using RabbitMQ - Multiple Producer and Multiple Consumers

I would like to know if it is possible to have multiples producers and multiple consumers?

For example:

-> Consumer A only receives message from Producer A

-> Consumer B only receives message from Producer B

Or Do i need to create multiple queues?

Can someone post and example?

Upvotes: 2

Views: 1781

Answers (2)

jamt
jamt

Reputation: 191

Short answer: You need to create multiple queues.

The queue is just that, an ordered sequence of messages, where you can access the messages in the order they arrived. This would make it unpractical to have messages for specific consumers on the same queue, since if the message isn't for your consumer, you would have to "give it back" to not lose it, but then it's foremost in the queue again and you would just get the same message again, unless you are lucky and the actual receiver gets it instead.

Multiple consumers on one queue is useful when you want to divide the load of processing the messages between multiple receivers, but if you want the messages to reach a specific endpoint, create a queue dedicated to that endpoint.

Upvotes: 1

deets
deets

Reputation: 6395

Just create multiple queues. They are at zero cost from RabbitMQ's point of view & exactly express your requirement.

Upvotes: 1

Related Questions