- parameters = pika.ConnectionParameters(‘localhost‘,5672,‘/‘,credentials ) #参数
- connection = pika.BlockingConnection(parameters) #连接
- channel = connection.channel() # 连接之后的 channel(引导)
- channel.queue_declare(queue=‘hello‘) # 申明
- print ‘ [*] Waiting for messages. To exit press CTRL+C‘
- def callback(ch, method, properties, body):
- print " [x] Received %r" % (body,)
- channel.basic_consume(callback,
- queue=‘hello‘,
- no_ack=True)
- channel.start_consuming()
参考链接:
http://blog.csdn.net/zyz511919766/article/details/41946521
时间: 2024-10-25 05:24:43