channel_pub = connection_pub.channel() channel_pub.exchange_declare(exchange='test', durable=True, passive=False) channel_pub.queue_declare(queue='test', durable=True, auto_delete=False, passive=False, exclusive=False) channel_pub.basic_publish(exchange='', routing_key='test', body=json.dumps(info), properties=pika.BasicProperties(delivery_mode=2, ))
关键点:queue的durable及信息的basic_publish.properties属性