delete the declared queue

This commit is contained in:
Kun Huang 2015-10-23 13:46:08 +08:00
parent abbbc744ba
commit decdeb5ed1

View File

@ -11,7 +11,7 @@ from kombu.mixins import ConsumerMixin
from kombu import Queue from kombu import Queue
task_exchange = Exchange('amq.rabbitmq.trace', type='topic') task_exchange = Exchange('amq.rabbitmq.trace', type='topic')
task_queues = [Queue("trace_", task_exchange, routing_key="publish.*")] task_queues = []
debug ={"method": set(), debug ={"method": set(),
"result": set()} "result": set()}
@ -53,9 +53,13 @@ class Worker(ConsumerMixin):
print "[result] %s\n" % oslo_body print "[result] %s\n" % oslo_body
with Connection('amqp://guest:guest@localhost:5672//') as conn: with Connection('amqp://guest:guest@localhost:5672//') as conn:
chan = conn.channel()
queue = Queue("trace_", task_exchange, routing_key="publish.*", channel=chan)
task_queues.append(queue)
try: try:
subprocess.check_call("sudo rabbitmqctl trace_on", shell=True) subprocess.check_call("sudo rabbitmqctl trace_on", shell=True)
worker = Worker(conn) worker = Worker(conn)
worker.run() worker.run()
except KeyboardInterrupt: except KeyboardInterrupt:
subprocess.check_call("sudo rabbitmqctl trace_off", shell=True) subprocess.check_call("sudo rabbitmqctl trace_off", shell=True)
queue.delete()