0

I am using the ActiveMQ "Classic" StatisticsPlugin to collect stats for destinations. I have used ActiveMQ.Statistics.Destination.* along with a replyTo header to collect the stats for all the topics. Unfortunately it's not working. It works if I use a named destination, but it's not working if i use wildcard.

            Connection connection = activeMQConnectionFactory.createConnection();
            connection.start();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

            Queue replyTo = session.createTemporaryQueue();
            MessageConsumer consumer = session.createConsumer(replyTo);

            MessageProducer producer = session.createProducer(null);

            // 
            String topicName = "ActiveMQ.Statistics.Destination.*";
            Topic query = session.createTopic(topicName);

            Message msg = session.createMessage();
            msg.setJMSReplyTo(replyTo);
            producer.send(query, msg);
            System.out.println("Message sent to wildcard topics.");

            MapMessage reply = (MapMessage) consumer.receive();
            // assertNotNull(reply);
            System.out.println("test");
            for (Enumeration e = reply.getMapNames(); e.hasMoreElements();) {
                String name = e.nextElement().toString();
                System.out.println(name + "=" + reply.getObject(name));
            }
            connection.close();

Could you please help me?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Developer
  • 239
  • 1
  • 3
  • 17

1 Answers1

0

To my knowledge the statistics broker plugin does not support query type lookup for multiple destination, you need to query each destination you want to collect data on. There are likely several reasons for this one of them being that the resulting message could end up being enormous if the broker has hundreds or thousands of destination and so some work would need to be put into how this would be handled as even if you chunked the results into multiple messages this could result in a broker running an extremely long task to collect this data possibly stalling other broker work.

You would likely be better off using the JMX management APIs to get insight into the broker and its destination as that feature has been much more developed than this simple statistics plugin that was mostly a tool for old STOMP clients to get some broker information.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42