0

Just doing some research for our Message Bus, I haven't got a straight answer from googling about whether RabbitMQ can provide persistence over public/subscribe method.

Eg. Subscriber A and B both subscribed to Publisher C, if Publisher C publishes a message while subscriber B is down, will subscriber B receive the message when it comes back up?

James Lin
  • 161
  • 3
  • 9

1 Answers1

0

The short answer is yes: RabbitMQ supports persistence of messages. For this to happen the message must be persistent (set in the client) and the queue(s) that it is routed to must be Durable. See more here.

In your question you muddle two concepts, "subscribers down" and "message persistence". If both A and B are only listening to one queue where one message was published it will be consumed by A. A will send an ack and the message will be removed from the queue = can't be processed by B when B comes back to the broker. If you want both A and B to consume the message you can do this in multiple ways, for example by using a fanout exchange and then set single active consumer on the queues bound to the exchange, where A and B both gets a single queue each.

jrhodin
  • 126
  • 3
  • 1
    If A & B both listening to the same queue then it's not publish/subscribe, but more like a worker pattern? Sorry I am new to this. – James Lin May 11 '21 at 02:12
  • Yes RabbitMQ supports any mix of work queuing and publish-subscribe. See for instance tutorial 3: https://www.rabbitmq.com/tutorials/tutorial-three-python.html – jrhodin May 12 '21 at 03:47