0
点赞
收藏
分享

微信扫一扫

rabbit mq 消费消息

雪域迷影 2022-02-27 阅读 53

 

import pika

auth = pika.PlainCredentials('admin', 'zyj@1985724')
connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.137.10',port=5672,virtual_host= '/', credentials=auth))
channel = connection.channel()

channel.queue_declare(queue='TEST01')

def callback(ch, method, properties, body):
   print(" [x] Received %r" % body)

channel.basic_consume(on_message_callback=callback,
                 queue='TEST01',
                 auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

 

举报

相关推荐

0 条评论