2 Replies Latest reply on Jan 13, 2015 6:44 AM by neraj sharma

    JMSQueueControl  removeAllMessages() not working for me

    neraj sharma Newbie

      I am facing problems with hornetq jmx in my integration tests and need your guidance on the same.



      I am using HornetQ version 2.2.13.Final in the project. Its a Spring based application. HornetQ is run in embedded fashion and started using JMSServerManager.start()



      The queueControl beans are created in the code as below:


      Following is the code taken from a class annotated with spring @Configuration



          public JMSQueueControl requestQueueControl() throws Exception {

              return queueControl(requestQueueDestination);



      private JMSQueueControl queueControl(String queueName) throws Exception {

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

              MBeanServerConnection mBeanServerConnection = connector().getMBeanServerConnection();

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

              return queueControl;





      I am running jmx server using:

      public void runJMXServer() throws UnknownHostException,

                  MalformedURLException, IOException {




              System.out.println("Get the platform's MBean server");

              MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();


              HashMap<String,Object> env = new HashMap<String,Object>();

              System.out.println("Create an RMI connector server");

              final String hostname = InetAddress.getLocalHost().getHostName();

              JMXServiceURL url =

                  new JMXServiceURL("service:jmx:rmi://"+hostname+



              // Now create the server for the JMXServiceURL

              JMXConnectorServer cs =

                  JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);


              // Start the RMI connector server.

              System.out.println("Start the RMI connector server on port "+3001);








      In my integration test I am doing the following




          private JMSQueueControl requestQueueControl;



      However when I invoke


      it doesn't result in removal of all messages from the queue


      I do not get any exceptions though



      requestQueueUtil.pause() is also not working



      Other methods like getMessageCount(), getMessagesAdded() are working as expected.



      How can I get requestQueueUtil.removeAllMessages(); to work