def mq_worker():
try:
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
channel.queue_declare(queue=mq_queue, durable=True)
channel.basic_qos(prefetch_count=1)
channel.basic_consume(callback,
queue=mq_queue)
channel.start_consuming()
except Exception as e:
connection.close()
mq_worker()
评论列表
文章目录