参考:http://rabbitmq.mr-ping.com/AMQP/AMQP_0-9-1_Model_Explained.html

import pika

# 链接 
connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost')) 

channel = connection.channel()

# 建立通道 
channel.queue_declare(queue='hello')
 

#定义回调函数
def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
 
# 传入消费者参数
channel.basic_consume(callback,
                      queue='hello',
                      no_ack=True)
 
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()   # 启动消费者
消费者

相关文章:

  • 2021-05-22
  • 2022-12-23
  • 2021-06-09
  • 2021-07-26
  • 2021-07-29
  • 2021-11-17
  • 2021-09-01
  • 2021-08-14
猜你喜欢
  • 2021-09-16
  • 2021-04-05
  • 2022-12-23
  • 2021-08-02
相关资源
相似解决方案