6 Replies Latest reply on Mar 30, 2012 4:15 AM by snoop.one

    listAllMessages of a JMS queue

    Mandar Kulkarni Newbie

      How can I get the list of all messages for a JMS queue in JBoss 7 ?


      Following code snippet throws the exception "javax.management.InstanceNotFoundException: org.hornetq:module=JMS,..........".


      ObjectName queueObjectName = new ObjectName("org.hornetq:module=JMS,name=\""+ queueName + "\",type=Queue");

      MBeanServerConnection server = ManagementFactory.getPlatformMBeanServer();

      JMSQueueControl queueControl = (JMSQueueControl)MBeanServerInvocationHandler.newProxyInstance(server,queueObjectName,JMSQueueControl.class,false);            

      return queueControl.countMessages(null);