Search code examples
rabbitmqjms

RabbitMQ point-to-point or pub-sub


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.


Solution

  • 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.