我们提供统一消息系统招投标所需全套资料,包括统一消息系统介绍PPT、统一消息系统产品解决方案、
统一消息系统产品技术参数,以及对应的标书参考文件,详请联系客服。
import pika
# 生产者
def send_message():
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='notification')
channel.basic_publish(exchange='', routing_key='notification', body='Hello, this is a message!')
print(" [x] Sent 'Hello, this is a message!'")
connection.close()
# 消费者
def receive_message():
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='notification')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(callback, queue='notification', no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
if __name__ == '__main__':
send_message()
# receive_message()