Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ point-to-point or pub-sub

Tags:

jms

rabbitmq

Is RabbitMQ point-to-point or pub-sub? Or both depending on configuration options?

I have been looking at the configurations, and they all seem to support the point-to-point model and not pub-sub. i.e. the message is removed from the queue once consumed, and is not available to a second consumer.

like image 582
Richard Avatar asked Dec 14 '22 12:12

Richard


2 Answers

Conceptually, RabbitMQ is both: point-to-point as well as pub-sub. You can register your listener application to the topic of an RabbitMQ exchange and receive all messages published to that Topic. So that is clearly 'pub-sub'. Whatever application architecture you have in mind, you can use the pub-sub concept to implement it.

However, just like IBM MQ, RabbitMQ started as a 'queuing system' (notice the MQ). So in order to implement pub-sub they simply built pub-sub on top of a queuing system. That works, but can feel kind of strange in terms of configuration (why would you need to setup an exchange at all, for example) and might not be as efficient as a messaging system that started with pub-sub in it's DNA.

If you only want to use pub-sub and have hundreds of consumers, there might be better choices, maybe messaging systems that use UDP multicast to distribute the data.

like image 53
Axel Podehl Avatar answered Dec 16 '22 00:12

Axel Podehl


If you wanted to use RabbitMQ as pub-sub, i.e. so the message is not removed by the first consumer, and can be consumed by many subscribers. How would you do figure RabbitMQ?

Use a fanout exchange. Each consumer declares its own exclusive queue, bound to that exchange. When a message is published to the exchange, it is routed to all queues bound to it.

Please read the RabbitMQ documentation and tutorials, which explain all of these concepts.


NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

like image 34
Luke Bakken Avatar answered Dec 16 '22 01:12

Luke Bakken