标签:receive bit eth print ram imp block connect close
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()
标签:receive bit eth print ram imp block connect close
原文地址:http://www.cnblogs.com/xiesongyou/p/7786786.html