8 Replies Latest reply on Aug 4, 2011 1:49 AM by ps_dash

    javax.management.InstanceNotFoundException: org.hornetq:module=JMS,type=Queue,name="AUALoggerQueue"

    ps_dash

      Hi,

       

      We are doing some benchmarking on hornetQ. So we need to check the enqueue, dequeue rate and number of messages in queue at a perticular instance of time.

       

      Our hornetQ 2.2.5 is intgrated with JBOSS 5.1.0 and the JMX port is enable at the port 3000 through the fallowing VM options

      -Dcom.sun.management.jmxremote
      -Dcom.sun.management.jmxremote.port=3000
      -Dcom.sun.management.jmxremote.ssl=false
      -Dcom.sun.management.jmxremote.authenticate=false

       

      But I'm not able to access the JMX management api. I'm getting the javax.management.InstanceNotFoundException: org.hornetq:module=JMS,type=Queue,name="AUALoggerQueue", while accessing JMSQueueControl object for messageCount().

       

      Fallowing are my JNDI properties

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

      java.naming.provider.url=jnp://localhost:1099

      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

      JNDI_NAME_Q=/queue/AUALoggerQueue

      JNDI_NAME_Q_CONNECTION_FACTORY=/ConnectionFactory

      JMX_URL = service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi

       

      My code looks like below:

      public class MessageCounter {

       

          private QueueConnection connection;

          private InitialContext initialContext;

          private QueueConnectionFactory qConnectionFactory;

          private Queue queue;

          private static final Logger LOGGER = Logger.getLogger(MessageCounter.class);

          private String JMX_URL = "";

          private JMSQueueControl queueControl;

       

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

              MessageCounter counter = new MessageCounter();

              counter.startCount();

          }

       

          private void startCount() throws Exception {

              try {

                  intialize();

                  int num = 1;

                  while (num <= 4) {

                      try {

                          Thread.sleep(15000);

                      } catch (InterruptedException ex) {

                                              LOGGER.error("", ex);

                      }

                      LOGGER.info("After " + 15 * num++ + " seconds");

                      LOGGER.info("Number of messages in Q: " + queueControl.getMessageCount());

                      LOGGER.info("Equeue count: " + queueControl.getMessagesAdded());

                      LOGGER.info("Dequeue count: " + queueControl.getDeliveringCount());

                  }

       

              } finally {

                  if (initialContext != null) {

                      initialContext.close();

                  }

                  if (connection != null) {

                      connection.close();

                  }

              }

          }

       

          private void intialize() throws Exception {

              Properties properties = loadProperties(

                               this.getClass().getResourceAsStream("/client-  jndi.properties"));

              doLookUps(getInitialContext(properties), properties.getProperty("JNDI_NAME_Q"),                               properties.getProperty("JNDI_NAME_Q_CONNECTION_FACTORY"));

              connection = qConnectionFactory.createQueueConnection();

       

              ObjectName on = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());

              JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap());

              MBeanServerConnection mbsc = connector.getMBeanServerConnection();

              queueControl = (JMSQueueControl) MBeanServerInvocationHandler.newProxyInstance(mbsc, on,                                                                       JMSQueueControl.class, false);

          }

       

          private Properties loadProperties(InputStream inputStream) throws IOException {

              Properties properties = new Properties();

              properties.load(inputStream);

       

              LOGGER.info("JNDI name for Q:" + properties.getProperty("JNDI_NAME_Q"));

              LOGGER.info("JNDI name for QueueConnectionFactory:" +                     properties.getProperty("JNDI_NAME_Q_CONNECTION_FACTORY"));

              LOGGER.info("JMX_URL: " + (JMX_URL=properties.getProperty("JMX_URL")));

              return properties;

          }

       

          private void doLookUps(Context context, String qJNDIName, String qConFcatoryJNDIName) throws                                                                                 NamingException {

              qConnectionFactory = (QueueConnectionFactory) context.lookup(qConFcatoryJNDIName);

              queue = (Queue) context.lookup(qJNDIName);

              context.close();

          }

       

          private InitialContext getInitialContext(Properties properties) throws NamingException,                                                             FileNotFoundException, IOException {

              return new InitialContext(properties);

          }

      }

       

      All the required jars are on the classpath.

       

      Any idea what is wrong??

       

      ----

      Regards,

      Partha Sarathi Dash