#!/usr/bin/python # -*- coding: utf-8 -*- # Display the contents of the queues. # # Note this cannot display messages which are being processed. # # This works by fetching the messages without acknowledging them, # effectively peeking into the queues. import email import json import pika import config connection = pika.BlockingConnection(pika.ConnectionParameters( host = config.mq_server)) channel = connection.channel() print "patchq_input (Unordered messages):" while True: method, _, body = channel.basic_get(queue = 'patchq_input', no_ack = False) if not method: break m = email.message_from_string(body) # the email # Only display the subject line. print (" %s" % m['Subject']) for t in config.tests: qname = "patchq_test_%s" % t print ("%s (Threads queued for %s):" % (qname, t)) while True: method, _, body = channel.basic_get(queue = qname, no_ack = False) if not method: break msgs = json.loads(body) msgs = [email.message_from_string(m) for m in msgs] print (" Thread:") for m in msgs: print (" %s" % m['Subject']) print "patchq_reports (Reports):" while True: method, _, _ = channel.basic_get(queue = 'patchq_reports', no_ack = False) if not method: break to, subject, ref, content = json.loads(body) print (" %s" % subject) print print "Note that messages being processed are not displayed. To see all" print "messages use ‘rabbitmqctl list_queues’ and other RabbitMQ admin tools."