📌  相关文章
📜  rabbitmq pika 用户名密码 - Python 代码示例

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

代码示例1
#!/usr/bin/env python
import pika

credentials = pika.PlainCredentials('the_user', 'the_pass')
parameters = pika.ConnectionParameters('132.45.23.14',
                                   5672,
                                   '/',
                                   credentials)

connection = pika.BlockingConnection(parameters)

channel = connection.channel()

channel.queue_declare(queue='hello', durable=Ture)

channel.basic_publish(exchange='',
                  routing_key='hello',
                  body='Hello W0rld!')
print(" [x] Sent 'Hello World!'")
connection.close()