title: Monitoring Queue using Java
body: <p>I am trying to monitor a queue without using any API such as Hermes or GEMS i.e. I want to use purely JAVA. SO in order to browse the queue i.e. check if message has reached the queue or not without actually consuming the message I have written below piece of code:</p>
  
  <pre><code>javax.jms.QueueBrowser browser = session.createBrowser(queue);
  
          Enumeration msgs = browser.getEnumeration();
  
          int Count=0;
  
          while(msgs.hasMoreElements())
          {
              message = (javax.jms.Message)msgs.nextElement();
              System.out.println("Message"+message);
              Count++;
          }
  </code></pre>
  
  <p>However when I am publishing the messages on queue it is not displaying the result. I have verified that messages are reaching the queue and same are being consumed by the receiver.
  So as this approach was not working I thought to use a different approach which is by counting the numberOfMessages recevied by queue before and after. So I used the below piece of code</p>
  
  <pre><code>QueueInfo q= new QueueInfo(queueName);
      long l=q.getInTransitMessageCount();
      System.out.println("In transit Mesasge Count="+l+"\n");
  </code></pre>
  
  <p>But this is also not working.
  Any suggestion or explanation to resolve this problem would be highly appreciated.
  Please note there is no compilation error in the code and all the necessary classes are imported.</p>