activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kureckam <mkure...@fractech.net>
Subject Queues not showing up using JMX
Date Fri, 14 Oct 2011 19:46:30 GMT
I'm trying to delete a dynamically created queue programmatically.  My
research seems to indicate that JMX is the best way to do this. I have
successfully created producer, consumers and queues. I can see the queues
using the web console http://localhost:8161/admin/queues.jsp but I can't see
any queues via the jconsole or via the program.  The program prints out 0
consumers, messages and queues. What am I doing wrong and how can I get it
to work?

xml file snippet:
   <amq:broker brokerName="fdsBroker"
               useJmx="true"
               persistent="true"
               schedulePeriodForDestinationPurge="10000">
      
      
      <amq:destinationPolicy>
         <amq:policyMap>
            <amq:policyEntries>
               
               
               <amq:policyEntry queue=">"
                                gcInactiveDestinations="true"
                                inactiveTimoutBeforeGC="30000" />
            </amq:policyEntries>
         </amq:policyMap>
      </amq:destinationPolicy>

      <amq:managementContext>
         <amq:managementContext connectorPort="2011"
                                jmxDomainName="my-broker" />
      </amq:managementContext>

      <amq:persistenceAdapter>
         
         <amq:kahaPersistenceAdapter directory="activemq-data"
                                     maxDataFileLength="1g" />
      </amq:persistenceAdapter>
      
      <amq:transportConnectors>
         <amq:transportConnector uri="tcp://localhost:0"
                                 discoveryUri="multicast://default" />
      </amq:transportConnectors>
   </amq:broker>

JMX test code:
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

import org.apache.activemq.broker.jmx.BrokerViewMBean;
import org.apache.activemq.broker.jmx.QueueViewMBean;

public class JMXTest
{
   public static void main(final String[] args)
   {
      try
      {
         final JMXServiceURL url = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2011/jmxrmi");
         final JMXConnector connector = JMXConnectorFactory.connect(url,
null);

         connector.connect();

         final MBeanServerConnection connection =
connector.getMBeanServerConnection();

         final ObjectName name = new
ObjectName("my-broker:BrokerName=fdsBroker,Type=Broker");

         final BrokerViewMBean mbean =
MBeanServerInvocationHandler.newProxyInstance(connection, name,
BrokerViewMBean.class, true);

         System.out.println("Statistics for broker " + mbean.getBrokerId() +
" - " + mbean.getBrokerName());
         System.out.println("\n-----------------\n");
         System.out.println("Total message count: " +
mbean.getTotalMessageCount() + "\n");
         System.out.println("Total number of consumers: " +
                            mbean.getTotalConsumerCount());
         System.out.println("Total number of Queues: " +
                            mbean.getQueues().length);

         for (final ObjectName queueName : mbean.getQueues())
         {
            final QueueViewMBean queueMbean =
MBeanServerInvocationHandler.newProxyInstance(connection, queueName,
QueueViewMBean.class, true);

            System.out.println("\n-----------------\n");
            System.out.println("Statistics for queue " +
queueMbean.getName());
            System.out.println("Size: " + queueMbean.getQueueSize());
            System.out.println("Number of consumers: " +
            queueMbean.getConsumerCount());
         }
      }
      catch(final Exception e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
}

--
View this message in context: http://activemq.2283324.n4.nabble.com/Queues-not-showing-up-using-JMX-tp3906002p3906002.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message