4 Replies Latest reply on Sep 20, 2005 3:12 AM by tomerbd2

    browsing messages in queue

    tomerbd2 Newbie

      Why isn't the following code browsing the messages in my queue? what is my mistake?

      public Enumeration listMessages() {
       QueueSession session = null;
       QueueBrowser browser = null;
       Enumeration queueContents = null;
       try {
       session = _queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
       queueContents = browser.getEnumeration();
       while (queueContents.hasMoreElements())
       _log.debug(queueContents.nextElement());
       } catch (JMSException e) {
       throw new InternalException(e);
       } finally {
       closeQueueBrowser(browser);
       closeSession(session);
       }
       return queueContents;
       }
      


      Thanks

        • 1. Re: browsing messages in queue
          Prasanna Bandaru Newbie

          Try this code it will work:


          public void browseQ() throws JMSException {
          QueueConnection queueConnection = null;
          QueueSession queueSession = null;
          QueueBrowser queueBrowser=null;
          queueConnection = QueueConnectionFactory.getInstance().getQueueConnection(channelName, hostName, queueManagerName);
          queueConnection.start();
          queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
          Queue responseQueue = QueueFactory.getInstance().getResponseQueue(queueSession, responseQueueName);
          queueBrowser=queueSession.createBrowser(responseQueue);
          Enumeration enumer=queueBrowser.getEnumeration();
          while (enumer.hasMoreElements())
          System.out.print(enumer.nextElement()+" ");
          }

          • 2. Re: browsing messages in queue
            tomerbd2 Newbie

            Hi

            What is this QueueFactory is it from jacorb.jar ? (in that jar there was such a class with no getInstance() method...)

            Thanks

            • 3. Re: browsing messages in queue
              tomerbd2 Newbie

              If i cancel / remove my queue receiver then i can see the messages in queuebrowser. My question is regarding the following scenario:

              1. I have a queue sender and a receiver
              2. I configure my sender to send more messages than the receiver can accept at any point of time
              3. I see that the JMS_MESSAGES table is getting filled with more and more messages more than the receiver can process
              4. I dont see any messages in the queueBrowser... Why is that?

              (Note that if i cancel the receiver work totally - which is an MDB then i do see the messages in the queuebrowser)

              • 4. Re: browsing messages in queue
                tomerbd2 Newbie

                ok its because there are parellal mdb receivers.