#测试RabbitMQ消息永久化
#1. 分队列永久化和信息永久化
#2. 意思为当服务重启后,队列和消息还存在,可供客户端接受
#3. 在服务器查看消息队列命令./rabbitmqctl list_queues

#send 端

import pika

credentials = pika.PlainCredentials('root', 'Password1')

connection = pika.BlockingConnection(pika.ConnectionParameters('10.3.151.86',5672,'/',credentials))

channel = connection.channel()

channel.queue_declare(queue='hello3',durable=True)   #durable=True 声明一个队列永久化(服务重启后还在)

channel.basic_publish(
    exchange='',
    routing_key='hello3',
    body='Hello Wfffforld!',
    properties=pika.BasicProperties(delivery_mode=2)
)
#properties=pika.BasicProperties(delivery_mode=2)  将消息永久化(服务重启后还在)

connection.close()