【发布时间】:2017-10-10 05:07:48
【问题描述】:
- 您好,我正在使用 stomp.py 模块发送和接收来自
的消息 使用 python 的 ActiveMQ。 - 在接收消息时,侦听器将在其中读取多条消息 指定的睡眠时间。
- 但我只需要阅读一条消息。在java中是可能的。如何 我可以使用 STOMP 从 ActiveMQ 读取一条消息吗?
这是我正在测试的监听器脚本,
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()
【问题讨论】:
-
嗨@Karthikeyan ..我也试图实现相同的场景,但使用AWS Lambda函数,但我收到错误说明 - “无法导入模块'lambda_function':没有名为'stomp'的模块" 如何在我的 AWS Lambda 函数中添加 stomp 依赖项。
-
@Kally 您需要将所有依赖模块捆绑到 zip 文件中。
-
谢谢@Karthikeyan 我使用了你的脚本,但我觉得我没有收到来自 MQ 的消息。任何建议