首页 > 其他 > 详细

新RabbitMQ精讲 提升工程实践能力 培养架构思维

时间:2021-03-11 10:28:32      阅读:20      评论:0      收藏:0      [点我收藏+]
新RabbitMQ精讲 提升工程实践能力 培养架构思维

V:ititit111222333

import pika
import time
from datetime import datetime

def callback(ch, method, porperties, body):
    print (‘*‘*16)
    print (str(datetime.now())[:-3], ‘new message on‘, method.exchange)
    print (str(datetime.now())[:-3], ‘routing key is: ‘, method.routing_key)
    print (str(datetime.now())[:-3], ‘type is: ‘, porperties.type)
    print (str(datetime.now())[:-3], ‘properties is: ‘, porperties)
    print (str(datetime.now())[:-3], ‘body is: ‘)
    print (str(datetime.now())[:-3], body)
    print (‘‘)

cred = pika.PlainCredentials(‘username‘,‘password‘)
con = pika.BlockingConnection(pika.ConnectionParameters(host =‘Ipaddress‘, credentials = cred))
chann = con.channel()
que = chann.queue_declare(queue="test",durable = False, exclusive = False)
key = ‘#‘
ex = ‘IGT.Exchange.Master‘
chann.queue_bind(exchange = ex, queue = que.method.queue, routing_key = key)
chann.basic_consume("test", callback, auto_ack=True)
print (‘ready to listen to ‘ + ex)
chann.start_consuming()

新RabbitMQ精讲 提升工程实践能力 培养架构思维

原文:https://blog.51cto.com/15063244/2655451

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!