I referred to the ActiveMQ Classic documentation to get statistics of broker/queues. This stats is needed to create some analysis. I tried as mentioned in the attached link but not able to fetch the stats with following code snippet. I see messages in ActiveMQ.Statistics.Broker queue but none in test queue.
Code snippet::
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")
Generally, Python is using STOMP protocol. Simply setup the statistics broker plugin on the server-side, then send the messages to the specially named queues, and subscribe to the response queues to get the output.