4 Replies Latest reply on Jul 27, 2015 10:12 AM by George Turner

    Cannot get list of topics using JMX

    George Turner Newbie

      I current have this code working fully, but I am using a static list of topic names.  I want to get the list from the default server, but I cannot get the correct method name to invoke.  I tried the "read-child-names" but got an error where the bug report said they were not going to open that access up.  So someone please tell me how to do this, it SHOULD be simple!


      StringBuilder sb = new StringBuilder("TOPIC_MONITORING\n");

          try {

            MBeanServer server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);

            for (String topicName : topicNames) {

              sb.append(String.format("%35s:", new Object[] { topicName }));

              ObjectName objectName = new ObjectName(new StringBuilder().append("jboss.as:subsystem=messaging,hornetq-server=default,jms-topic=").append(topicName).toString());

              Object subscriptionCount = server.getAttribute(objectName, "subscriptionCount");

              Object messageCount = server.getAttribute(objectName, "messageCount");

              Object messagesAdded = server.getAttribute(objectName, "messagesAdded");

              sb.append(String.format("%20s:%10d", new Object[] { "subscriptionCount", subscriptionCount }));

              sb.append(String.format("%20s:%20d", new Object[] { "messageCount", messageCount }));

              sb.append(String.format("%20s:%20d", new Object[] { "messagesAdded", messagesAdded }));



          } catch (Exception e) {

            logger.error("error checking topics", e);