参考: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() # 启动消费者