[jboss-user] [JBoss Messaging] - Re: Queue MessageCount - JMX Help

mskonda do-not-reply at jboss.com
Fri May 25 04:28:32 EDT 2007


You can locate/create a Queue/TopicMBean by following method (from Kabutar):

  |  private void initDestinationInfo(String destName, String type)
  |     {
  | 
  |         try
  |         {
  | 
  |             mBeanServer = JMXUtil.getMBeanServer(ContextUtil.getContext());
  | 
  |             serverObjectName = new ObjectName(
  |                     "jboss.messaging.destination:service=" + type + ",name="
  |                             + destName);
  |             if (type.equalsIgnoreCase(Destination.QUEUE))
  |             {
  | 
  |                 queueMBean = (QueueMBean) MBeanServerInvocationHandler
  |                         .newProxyInstance(mBeanServer, serverObjectName,
  |                                 QueueMBean.class, false);
  |                 setIsQueue(true);
  | 
  |             } else if (type.equalsIgnoreCase(Destination.TOPIC))
  |             {
  | 
  |                 topicMBean = (TopicMBean) MBeanServerInvocationHandler
  |                         .newProxyInstance(mBeanServer, serverObjectName,
  |                                 TopicMBean.class, false);
  |                 setIsQueue(false);
  |             }
  | 
  |         } catch (NamingException e)
  |         {
  |             logger.warn("NamingException:" + e.getMessage());
  |             logger.error(e);
  |         } catch (Exception e)
  |         {
  |             logger.info("Exception:" + e.getMessage());
  |             logger.error(e);
  |         }
  |     }
  | 

Once you get the Queue/TopicMBean, all you have to do is to invoke approriate methods:

  | qMBean.getMessageCount()
  | qMBean.getConsumerCount()
  | etc..
  | 

You get the idea, didn't you? 

You can browse the above code in Kabutar: 

http://kabutar.googlecode.com/svn/trunk/src/com/agilyx/kabutar/browser/jms/


Thanks
Madhu


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048608#4048608

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048608



More information about the jboss-user mailing list