Unable to retrieve broker statistics from a destination using the broker statistics plugin

Solution Verified - Updated -


  • Using the example provided in the Apache documentation [1] on retrieving destination statistics, the program never returns any information on the destination.

The following is an example of code executed:

package example;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTopic;

import java.util.Enumeration;

import javax.jms.*;

class DestinationStats {

    public static void main(String []args) throws JMSException {

        String user = env("ACTIVEMQ_USER", "admin");
        String password = env("ACTIVEMQ_PASSWORD", "admin");
        String host = env("ACTIVEMQ_HOST", "localhost");
        int port = Integer.parseInt(env("ACTIVEMQ_PORT", "61616"));
        String dest = env("ACTIVEMQ_DESTINATION", "FOO");

        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://" + host + ":" + port);

        Connection connection = factory.createConnection(user, password);
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

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

        String queueName = "ActiveMQ.Statistics.Destination." + dest;
        System.out.println("Queue Set to: " + queueName);
        Queue testQueue = session.createQueue(queueName);
        MessageProducer producer = session.createProducer(testQueue);
        Message msg = session.createMessage();

        MapMessage reply = (MapMessage) consumer.receive();

        if(reply != null){

           for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
             String name = e.nextElement().toString();
             System.out.println(name + "=" + reply.getObject(name));
            System.out.println("Reply was null!");


    private static String env(String key, String defaultValue) {
        String rc = System.getenv(key);
        if( rc== null )
            return defaultValue;
        return rc;

    private static String arg(String []args, int index, String defaultValue) {
        if( index < args.length )
            return args[index];
            return defaultValue;

[1] http://activemq.apache.org/statisticsplugin.html


  • JBoss Fuse A-MQ 6.1
  • apache-activemq-5.9.0.redhat-610379

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content