7 Replies Latest reply: Jul 8, 2010 3:47 AM by 805009 RSS

    Queuebrowser getEnumeration() failing to return all messages

      I am using open mq in LOCAL mode in an glassfish v2 ur2 app server.
      My application is multithreaded.
      When I call the getEnumeration() method of QueueBrowser with small numbers of messages (<500) I get the correct count. However when I have about 900 messages in a queue, not all the messages are returned. The actual number returned varies. I suspected it may have been a timing issue (the browser may need time to gather all the messages) so i implemented a thread sleep after Connection.start() was called but before getEnumeration() was called. This did not really help.

      here is a code snippet:
            browser = session.createBrowser(queue,selector);
            logger.info("using selector "+browser.getMessageSelector());
            try {
            } catch (InterruptedException ee) {
            Enumeration msgs;
            for (msgs = browser.getEnumeration() ; msgs.hasMoreElements() ;){
              Message m = (Message) msgs.nextElement();
            logger.info("Got "+list.size() +" messages ");
      I have tried using REMOTE and EMBEDDED brokers, and also switching away from the standard derby backend and using oracle. all to no avail.
      If anyone has any ideas i'd gratefully receive these.


        • 1. Re: Queuebrowser getEnumeration() failing to return all messages
          A couple of questions ...

          * Are you using a cluster ? Browse will only receive messages off of a single broker (its documented as a limitation of clusters in the release notes)

          Queues receive sets of messages in a chunk and have a specific timeout value. You may need to modify those:



          • 2. Re: Queuebrowser getEnumeration() failing to return all messages
            thanks for that Linda, it was helpful.

            However I tried setting these two attributes and it still came back with the original problem.

            I was unsure where to set them, so I set them as jvm properties
            and also as additional properties for the javax.jms.QueueConnectionFactory I set up as my jms Connectionfactory in glassfish

            I did this using the glassfish admin webpage

            perhaps I am setting these attributes in the wrong place ?

            Can you give me some more pointers ?

            Thanks in advance.
            • 3. Re: Queuebrowser getEnumeration() failing to return all messages
              I am not using a cluster.

              There is some random behaviour involved because I know that there are 999 messages in the queue, but the number brough back by the browser varies (but is always below this).

              Once the QueueBrowser enumerates the messages, closing it, and then creating a new one and enumerating again brings back the same message count.

              Update: I've found that reducing the size of the messages in the queue means I am able to enumerate more of them with the browser. Suggesting that it may be a timing / data load related issue.

              Edited by: philestine on Nov 14, 2008 8:02 AM
              • 4. Re: Queuebrowser getEnumeration() failing to return all messages
                I still cannot get this to work.
                I have tried altering these attributes to various values, but it makes no difference.
                Probably because they are still not being set:

                I get this error:

                [#|2008-11-17T13:25:48.872+0000|WARNING|sun-appserver9.1|javax.enterprise.resource.resourceadapter|_ThreadID=18;_ThreadName=p: thread-pool-1; w: 3;setImqQueueBrowserRetrieveTimeout;com.sun.messaging.jms.ra.ManagedConnectionFactory;_RequestID=c76a233d-fd8e-4af2-b1f8-4dd4ff65468f;|RAR8000 : The method setImqQueueBrowserRetrieveTimeout is not present in the class : com.sun.messaging.jms.ra.ManagedConnectionFactory|#]

                [#|2008-11-17T13:25:48.872+0000|WARNING|sun-appserver9.1|javax.enterprise.resource.resourceadapter|_ThreadID=18;_ThreadName=p: thread-pool-1; w: 3;imqQueueBrowserRetrieveTimeout;com.sun.messaging.jms.ra.ManagedConnectionFactory;_RequestID=c76a233d-fd8e-4af2-b1f8-4dd4ff65468f;|RAR7097: No setter method present for the property imqQueueBrowserRetrieveTimeout in the class com.sun.messaging.jms.ra.ManagedConnectionFactory

                Please tell me how I am supposed to set the properties you suggested above ?

                Setting them as additional properties via the glassfish admin concole does not work.

                Thanks in advance,

                • 5. Re: Queuebrowser getEnumeration() failing to return all messages
                  I have exactly the same issue a queue with a lot of messages and only getting some.
                  I'm trying to browse a queue in ActiveMQ 5.2.
                  Does anybody solved this? Can it be a bug?

                  Here is a stub of the code:
                  if (browser != null) {
                    Enumeration elements = browser.getEnumeration();
                    while(elements.hasMoreElements() == true){
                      javax.jms.Message m = (javax.jms.Message) elements.nextElement();
                  • 6. Re: Queuebrowser getEnumeration() failing to return all messages
                    Perhaps it could be something like the drivers for the backend database are out of date. We noticed odd things happening when we were using Oracle as the backend to JMS and we weren't working with the latest ojdbc jar for the database version. Might it be something like that ?
                    • 7. Re: Queuebrowser getEnumeration() failing to return all messages
                      @juan_garcia - Please note that this forum is for Sun Java System Message Queue (also known as Glassfish Message Queue or Open Message Queue) so you won;t find many Apache ActiveMQ users or developers here. Nigel