3 Replies Latest reply on Jul 18, 2011 2:01 AM by Andy Taylor

    Queue Size while in OnMessage

    java into Newbie

      Hi,

      What is the mechanism if any wherein if i am inside OnMessage method then i can retrieve how many entries are more present in the hornet queue which has been defined.

      So basically how to determine the size of the queue while inside onmessage()

       

      Thanks

        • 1. Re: Queue Size while in OnMessage
          java into Newbie

          ClientSession.QueueQuery qq =  consumerSession.queueQuery(sQueueName);

                      inQueueMessageCount = qq.getMessageCount();

          I have done this inside onMessage where i have a single instance from where i get the coresession and do a query an get messageCount.

          Is this a right approach  ?

          • 2. Re: Queue Size while in OnMessage
            java into Newbie

            Ok so what i did above did give the queue Message count as was desired but now i have a question

            I printed the MessageCount in every OnMessage() and what i observed is that the message count is kind of something which is not dynamic but rather changes or is refered in certian time interval. So instead of getting 1000..999..998..997...if the message were consumer out of the queue what i got is 1239,1239,1239...a lot of 1239....982..lot of 982's and then reduce ...

             

              [log] Message Count in Queue is 1239

             

                 [exec] 05:02:07,475 INFO  [log] Message Count in Queue is 1239

             

                 [exec] 05:02:07,476 INFO  [log] Message Count in Queue is 1239

             

                 [exec] 05:02:07,480 INFO  [log] Message Count in Queue is 982

             

                 [exec] 05:02:07,481 INFO  [log] Message Count in Queue is 982

             

                 [exec] 05:02:07,481 INFO  [log] Message Count in Queue is 982

             

             

            What is the expalnation on this... How can i get a dynamic message count ?

            • 3. Re: Queue Size while in OnMessage
              Andy Taylor Master

              this is because we ack messages in batches, if you changed this to 0 you would  ack every message individually and see the queue count decrease 1 at a time