如何在 Python 中访问 ActiveMQ "Classic" 统计插件



我指的是ActiveMQ "Classic"获取代理/队列统计信息的文档。创建一些分析需要这些统计数据。我尝试了在所附链接中提到的,但无法获取以下代码片段的统计数据。我在中看到消息ActiveMQ.Statistics.Brokertest队列。

代码片段::

self.conn = stomp.Connection([('localhost', 61616)] , keepalive=True, try_loopback_connect=True, reconnect_attempts_max=3,)
self.conn.set_listener("testlistener", TestListener(print_to_log=True))
# couple of more listeners for some existing purpose


def retrieve_stats(self) -> None:
print("*************START*****************n")
self.conn.subscribe(id=time.time(), destination="/queue/test") # created a new queue where stats can be pushed
self.conn.send(
body="",
destination="/queue/ActiveMQ.Statistics.Broker",
content_type="text/blah",
headers={
"amq-msg-type": "text",
"persistent": "true",
"reply-to": "/queue/test",
},
)
broker_stat_listener = self.conn.get_listener("testlistener")
if len(broker_stat_listener.message_list) > 0:
print(broker_stat_listener.message_list.__str__())
print("*************END*****************n")

输入图片描述

一般来说,Python使用STOMP协议。只需在服务器端设置统计代理插件,然后将消息发送到专门命名的队列,并订阅响应队列以获得输出。

ref: Example python + stomp listener

最新更新