0 Replies Latest reply on Oct 3, 2001 5:34 PM by Jason Vasquez


    Jason Vasquez Newbie

      I'm fairly new to JMS, so maybe I'm just missing something. I have a tool to add messages to a queue, and one system acting as a message listener. For testing, I put a 10 second artificial delay into my listener.

      I expected that I would be able to pile up a few messages on the queue, and use QueueBrowser to get a count of how many were waiting, since the listener only processes 1 every 10 seconds. The weird thing is that the enumeration returned from QueueBrowser.getEnumeration always has 0 elements in it, even when the listener is sleeping with several more messages to go.

      Am I missing something here?

      (BTW, here's the code from the listener):

       Context ctx = new InitialContext();
       QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup("java:comp/env/jms/QueueFactory");
       Queue jobQueue = (Queue)ctx.lookup("java:comp/env/jms/search/JobQueue");
       QueueConnection qConn = qcf.createQueueConnection();
       QueueSession qSession = qConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
       QueueBrowser qb = qSession.createBrowser(jobQueue);
       Enumeration enum = qb.getEnumeration();
       int count = 0;
       while (enum.hasMoreElements()) {
       System.out.println(count + " messages sitting on the queue");