2 Replies Latest reply on Sep 13, 2004 12:41 AM by Deepak Nohwal


    Deepak Nohwal Newbie


      I am new to JMX and here is what I want to achieve.

      I want to know the depth of a JMS queue which is existing on JBoss called "testQueue". Please note that I am able to send messages to this queue using my JMS application. Now, to find out this depth I want to access "QueueDepth" attribute of the "testQueue" MBean. Here is how my client code looks like:


      Hashtable prop = new Hashtable();
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
      prop.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      Context c = new InitialContext(prop);
      RMIAdaptor a = (RMIAdaptor)c.lookup("jmx/rmi/RMIAdaptor");
      MBeanServer mbeanServer = new RMIConnectorImpl(a);

      ObjectName objName = new ObjectName("jboss.mq.destination" , "Queue" , "testQueue");

      Object depthObj = mbeanServer.getAttribute(objName, "MessageCounter");

      System.out.println("The depth of queue is: " + ((Integer)depthObj).intValue());


      When I run it, it gives me the following error:

      javax.management.InstanceNotFoundException: jboss.mq.destination:Queue=testQueue is not registered.
      at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:354)
      at org.jboss.mx.server.MBeanServerImpl.getAttribute(MBeanServerImpl.java:442)


      Please note that I am able to view this queue using JMX console and as I have already mentiuoned that I am able to send messages to this queue. The JMX console shows the following values for this queue:

      Domain jboss.mq.destination
      service Queue
      name testQueue

      Any clue what am I doing wrong? Please treat this as urgent.