I would like to get a copy of the messages present in a Rabbitmq queue without consuming them. Is it possible ? Thanks in advance,
I would like to get a copy of the messages present in a Rabbitmq queue without consuming them. Is it possible?
No. The closest option you have is to consume or get a message and then reject it via a negative acknowledgement.
may be you can register a consumer (as shown here in the official doc) without giving ack to the broker: no_ack=True
channel.basic_consume(callback, queue='hello', no_ack=True)
This way your consumer receives the message content but the message itself is not marked as delivered by the broker (and returns to Ready state when you consumer exits).
May be this is not the cleanest way to do what you need, but it works and it's simple.
Another (but similary) approach you can adopt is based on the so-called pull API (in opposite to push API you use when you register a subscriber); I used this approach in a .Net application: you can find the .Net documentation here and I think Python APIs are similar in that, too.
The key idea is to get a message without giving ack: channel.BasicGet(queueName, noAck)
I hope this can help you to move towards a full and reliable solution!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With