0
- 嗨,我使用stomp.py模块来发送和接收来自
使用python的消息。 - 虽然接收消息侦听器将读取 指定的睡眠时间内的多个消息。
- 但我只需要阅读一条消息。这是可能的在Java中。如何使用STOMP从ActiveMQ读取单个消息?
下面是我测试的听者脚本,使用python从ActiveMQ队列接收单条消息STOMP
import stomp
import time
class SampleListener(object):
def on_message(self, headers, msg):
print(msg)
conn = stomp.Connection([('localhost',61613)])
conn.set_listener('SampleListener', SampleListener())
conn.start()
conn.connect()
conn.subscribe(destination='queue_name', id=1, ack='auto')
time.sleep(10) # secs
conn.disconnect()