python+stomp+activemq
2014-12-09 19:10
302 查看
python也可以连接MQ,以ActiveMQ为例,安装stomp.py:
https://github.com/jasonrbriggs/stomp.py
下载后安装:
python setup.py install
很简单,然后一个简单的示例:
好了,可以发送、接收消息了!
https://github.com/jasonrbriggs/stomp.py
下载后安装:
python setup.py install
很简单,然后一个简单的示例:
import time import sys import stomp class MyListener(object): def on_error(self, headers, message): print('received an error %s' % message) def on_message(self, headers, message): print('received a message %s' % message) #官方示例的连接代码 #conn = stomp.Connection([('ip...',61613)])
conn.set_listener('', MyListener()) conn.start() conn.connect() conn.subscribe(destination='/queue/test', id=1, ack='auto') #注意,官方示例这样发送消息的 $ python simple.py hello world #conn.send(body='hello,garfield! this is '.join(sys.argv[1:]), destination='/queue/test') conn.send(body='hello,garfield!', destination='/queue/test') time.sleep(2) conn.disconnect()
好了,可以发送、接收消息了!
相关文章推荐
- python+stomp+activemq
- Easy Messaging with STOMP over WebSockets using ActiveMQ and HornetQ
- How does ActiveMQ compare to AMQP(Stomp和OpenWire)
- 搭建Spring4.1与Spring4.2 websock+stomp+activeMQ需要注意事项:spring4不同版本websocket差异
- ActiveMQ + NodeJS + Stomp 入门
- ActiveMQ + NodeJS + Stomp 极简入门
- ActiveMQ+STOMP协议构建消息队列
- python activemq操作: consumer
- ActiveMQ + NodeJS + Stomp 极简入门
- php+stomp+activemq,实现producer
- ActiveMQ + NodeJS + Stomp 极简入门
- ActiveMQ + NodeJS + Stomp 极简入门
- activeMQ+stomp+php实现消息队列
- ActiveMQ + NodeJS + Stomp 极简入门
- nagios通过python监控zookeeper+activemq
- ActiveMQ + 中间件 项目研究
- ActiveMQ in Action(7)
- ActiveMQ in Action(4)
- 对 ActiveMQ .NET 1.1.0 组件接受中文信息乱码的修复
- jms activeMQ 应用