📌  相关文章
📜  pika.exceptions.channelclosedbybroker:(406,“precondition_failed - vhost'fx'中队列'fx-naas'的不等价arg'durable':r - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:14.532000             🧑  作者: Mango

代码示例1
# This script will publish MQ message to my_exchange MQ exchange

import pika
#credentials = pika.PlainCredentials('the_user', 'the_pass')
#connection = #pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', pika.PlainCredentials('guest', 'guest')))
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, 'test', pika.PlainCredentials('admin', 'password1243')))
channel = connection.channel()

#channel.queue_declare(queue='items-queue', durable=Ture)
channel.queue_declare(queue='dx-naas', durable=True)


channel.basic_publish(exchange='my-exchange', routing_key='my-routing-key', body='Hello World!')

print("[x] Sent 'Hello World!'")

connection.close()