Python 官方文档:入门教程 => 点击学习
#!/usr/bin/env python#-*- coding: utf8 -*- import pikaimport tracebacktry: connection = pika.BlockinGConnection(pika.
#!/usr/bin/env python
#-*- coding: utf8 -*-
import pika
import traceback
try:
connection = pika.BlockinGConnection(pika.ConnectionParameters(host='192.168.4.226'))
channel = connection.channel()
except:
print traceback.print_exc()
def RabbitMQ_send(abcde):
try:
channel.queue_declare(queue='abcde')
except:
print traceback.print_exc()
try:
mess = "<message><name>abcde</name><item key='abcde'>%s</item></message>" %abcde
channel.basic_publish(exchange='',
routing_key='abcde',
body = mess)
print '[x] Send abcde'
except:
print traceback.print_exc()
try:
connection.close()
except:
print traceback.print_exc()
if __name__ == "__main__":
sc = rabbitMQ_send('abcde')
--结束END--
本文标题: python rabbitmq send
本文链接: https://lsjlt.com/news/187447.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0