Apparently there is no easy way to look at the content of messages in RabbitMQ. the list_queues only will give you a count but if you want to look at all the messages content then there is no easy way. I had few thumbnail generation messages in the queue that the code failed to ACK because of exceptions in code. Now I want to see what files are stuck for thumbnail generation. The best way is to restart the program and Rabbit would redeliver the messages but we cant restart a live system. So the trick is to just write a python program that would consume the message but wont acknowledge it.
import sys from amqplib import client_0_8 as amqp def process_message(msg): print "=================================================" print "Properties =" print msg.properties print "Body=" print msg.body if __name__ == '__main__': if len(sys.argv) < 5: print "Usage python list_queue_messages.py mq_url mq_user mq_pass mq_vhost mq_exchange mq_queue_name mq_routing_key" exit() mq_url = sys.argv mq_user = sys.argv mq_pass = sys.argv mq_vhost = sys.argv mq_exchange = sys.argv mq_queue_name = sys.argv mq_routing_key = sys.argv conn = amqp.Connection(host=mq_url, userid=mq_user, password=mq_pass, virtual_host=mq_vhost, insist=False); chan = conn.channel(); chan.queue_declare(queue=mq_queue_name, durable=True, exclusive=False, auto_delete=False); chan.exchange_declare(exchange=mq_exchange, type="direct", durable=True, auto_delete=False); chan.queue_bind(queue=mq_queue_name, exchange=mq_exchange, routing_key=mq_routing_key) print "Consumer consuming messages from %s press CTRL+C when all messages are dumped" % mq_queue_name chan.basic_consume(queue=mq_queue_name, no_ack=False, callback=process_message) try: while chan.callbacks: chan.wait(); finally: chan.close(); conn.close();