Reputation: 6149
I have 2 questions regarding rabbitmq consumers (receivers):
Thanks
Upvotes: 0
Views: 1315
Reputation: 10170
To achieve what you want is simple, this is by design in rabbitmq (just be sure that you don't auto-acknowledge). The message remains in the queue until it's acknowledged. So basically the consumer should finish processing the message and then acknowledge it. If the consumer dies during processing, the message is not ACKed and it gets re-queued. Next time the consumer is up it gets that message. Of course if you have multiple instances of the same (for the sake of simplicity) consumers, the one that is up takes the re-queued message. It's nicely explained in the second tutorial on rmq website.
Declaring queue is an idempotent operation, the queue will be created if it doesn't exist already. If the consumer is the first one to create the queue, that's fine, it's actually usually how it works. The publisher actually does not even (need to) know about the queue, it only cares about exchanges and routing keys. It also doesn't care if anyone is listening, it simply publishes the message. The consumer needs to tell to what routing key does it want to bind the queue.
Upvotes: 3