Source

bunny / monitor / exclusiveQueue.py

Full commit
#!/usr/bin/env python
from base64 import decodestring
import pika

credentials = pika.PlainCredentials("fiver", "ilovemybunnyfriends")
conn_params = pika.ConnectionParameters("localhost",
                                        virtual_host="warren",
                                        credentials=credentials)

conn_broker = pika.BlockingConnection(conn_params)

channel = conn_broker.channel()

channel.exchange_declare(exchange="amq.direct",
                         type="direct", durable=True)

result = channel.queue_declare(exclusive=True, auto_delete=True)
queue_name = result.method.queue

channel.queue_bind(queue=queue_name,
                   exchange="amq.direct",
                   routing_key="")

def msg_consumer(channel, method, header, body):
    print body
    return

channel.basic_consume(msg_consumer,
                      queue=queue_name,
                      consumer_tag="test-consumer")

channel.start_consuming()