【发布时间】:2021-03-02 11:57:58
【问题描述】:
我正在尝试使用stompest 订阅在localhost 中运行的ActiveMQ 中的主题以连接到代理。请参考以下代码:
import os
import json
from stompest.sync import Stomp
from stompest.config import StompConfig
CONFIG = StompConfig(uri=os.environ['MQ_URL'],
login=os.environ['MQ_UID'],
passcode=os.environ['MQ_DWP'],
version="1.2")
topic = '/topic/SAMPLE.TOPIC'
msg = {'refresh': True}
client = Stomp(CONFIG)
client.connect()
client.send(topic, json.dumps(msg).encode())
client.disconnect()
client = Stomp(CONFIG)
client.connect(heartBeats=(0, 10000))
token = client.subscribe(topic, {
"ack": "client",
"id": '0'
})
frame = client.receiveFrame()
if frame and frame.body:
print(f"Frame received from MQ: {frame.info()}")
client.disconnect()
虽然我看到 ActiveMQ Web 控制台的活动连接,但代码中没有收到任何消息。控制流似乎在frame = client.receiveFrame() 处暂停。
我没有找到任何可靠的资源或文档。
我在这里做错了吗?
【问题讨论】:
标签: python-3.x activemq stomp jms-topic