Commit 11d9dcb4 by 岳巧源

add pika version

parent 325a8d95
Showing with 5 additions and 3 deletions
......@@ -25,9 +25,11 @@ def listen_from_mq():
credentials=credentials))
channel = conn.channel()
channel.queue_declare(queue=config.rabbit_mq_queue_consumer, durable=True)
# 注意 py3.8 的api 和 python3.6的api 是有区别的
# channel.basic_consume(callback, queue=config.rabbit_mq_queue_consumer)
channel.basic_consume(queue=config.rabbit_mq_queue_consumer, on_message_callback=callback)
"""测试环境和生产环境的pika版本不同"""
if pika.__version__[0] == "1":
channel.basic_consume(queue=config.rabbit_mq_queue_consumer, on_message_callback=callback)
else:
channel.basic_consume(callback, queue=config.rabbit_mq_queue_consumer)
channel.start_consuming()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment