0 Replies Latest reply on Sep 19, 2010 4:06 PM by Jimmy Beagle

    Is there a way to list all the queues in the system?

    Jimmy Beagle Newbie

      I'm using the code below to get a list of message counts for a particular queue, is there a way I can get a list of all queues in hornetq so I don't have to pass in a queuename manually?

       

       

       

      public static int getMessageCount(final Connection connection, String queueName) throws Exception
        {
           QueueSession session = ((QueueConnection)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
           Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management");
           QueueRequestor requestor = new QueueRequestor(session, managementQueue);
           connection.start();
           Message m = session.createMessage();
           JMSManagementHelper.putAttribute(m, queueName, "messageCount");
           Message response = requestor.request(m);
           int messageCount = (Integer) JMSManagementHelper.getResult(response);
           if(session != null) { try { session.close(); } catch(Exception e) { e.printStackTrace(); }}
           if(connection != null) { try { connection.close(); } catch(Exception e) { e.printStackTrace(); }}
           return messageCount;
        }
      public static int getMessageCount(final Connection connection, String queueName) throws Exception
        {
           QueueSession session = ((QueueConnection)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      
           Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management");
      
           QueueRequestor requestor = new QueueRequestor(session, managementQueue);
      
           connection.start();
      
           Message m = session.createMessage();
      
           JMSManagementHelper.putAttribute(m, queueName, "messageCount");
      
           Message response = requestor.request(m);
      
           int messageCount = (Integer) JMSManagementHelper.getResult(response);
      
           if(session != null) { try { session.close(); } catch(Exception e) { e.printStackTrace(); }}
           if(connection != null) { try { connection.close(); } catch(Exception e) { e.printStackTrace(); }}
      
           return messageCount;
        }