3 Replies Latest reply on Jan 18, 2011 11:41 AM by Clebert Suconic

    Browse Queue Removing Message From Queue

    Osian Hughes Newbie



      I am attempting to browse a queue to see if it is empty before I shut down my in vm server, but unfortunately it seems that even if I set browseOnly to be true, it seems to remove the message from the queue when I use receiveImmediate() (or any other receive method).


      Here is the source I am using:


      public boolean isQueueEmpty(String queueName) throws HornetQException {

           Session queueBrowserSession = factory.createSession();

           ClientConsumer consumer = queueBrowserSession.createConsumer(queueName, true);

           return consumer.receiveImmediate() == null;



      Does anyone have any thoughts? Or is what I'm trying to achieve not possible?