Python 推送RabbitMQ
Posted xuchunlin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python 推送RabbitMQ相关的知识,希望对你有一定的参考价值。
username = ‘xxxxxxxx‘ pwd = ‘xxxxxxxx‘ user_pwd = pika.PlainCredentials(username, pwd) s_conn = pika.BlockingConnection(pika.ConnectionParameters(‘110.318.111.211‘, credentials=user_pwd)) chan = s_conn.channel() queuename = "pre_weibo_test" exchange = "pre_weibo_test_exchange" routkey = "pre_weibo_test" chan.exchange_declare(exchange,"topic") chan.queue_declare(queue=queuename) chan.queue_bind(queue=queuename, exchange=exchange, routing_key=routkey) chan.basic_publish(exchange=exchange,routing_key=routkey,body=‘ json data1‘) s_conn.close()
以上是关于Python 推送RabbitMQ的主要内容,如果未能解决你的问题,请参考以下文章
RabbitMQRabbitMQ和Erlang下载与安装步骤—2023超详细最新版