python rabbit MQ
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python rabbit MQ相关的知识,希望对你有一定的参考价值。
produce:
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters("localhost") )
channel=connection.channel()
channel.queue_declare(queue="hello")
channel.basic_publish(exchange=‘‘,routing_key="hello",body="Hello World")
print("sent ‘hello world")
connection.close()
consumer:
import pika
connection=pika.BlockingConnection (pika.ConnectionParameters("localhost"))
channel=connection.channel()
channel.queue_declare(queue="hello")
def callback(ch,method,properties,body):
# print(ch)
# print(method)
# print(properties)
print("Received %r"%body)
channel.basic_consume(callback,queue=‘hello‘,no_ack=True)
print("wait ....")
channel.start_consuming()
以上是关于python rabbit MQ的主要内容,如果未能解决你的问题,请参考以下文章
rabbit is rabbit on the table,解释rabbit
SQL Server数据库mdf文件中了勒索病毒Rabbit4444。扩展名变为Rabbit4444