📅  最后修改于: 2022-03-11 14:59:14.532000             🧑  作者: Mango
# 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()