8 Replies Latest reply on Aug 4, 2011 1:49 AM by Partha Sarathi Dash

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

    Partha Sarathi Dash Newbie



      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



      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






      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();




          private void startCount() throws Exception {

              try {


                  int num = 1;

                  while (num <= 4) {

                      try {


                      } 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) {



                  if (connection != null) {






          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();



              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);




          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??




      Partha Sarathi Dash