2 Replies Latest reply on Jun 29, 2011 10:27 AM by Clebert Suconic

    a problem of the message number in the queue

    Tim White Newbie

      I use the JMX to get the message count in the queue,and I have a problem.


      First , I create a producer to send one message every second , and create a consumer receive one message then sleep 1 second in another thread


      Then, I use the JMX management tools to get the meesage count in the queue, the following is the result :


      Cousumer : [{"sessionID":"d84784fc-a21a-11e0-8bf7-001b21a7f0e0","connectionID":"6457059","creationTime":1309330481166,"browseOnly":false,"consumerID":0}]

      current message count:578





      the current message count is the getMessageCount() method's result

      the countMessage is countMessages(null) method's result

      And then , I listMessagesAsJSON(null) to get all the message details in the queue.


      I think the message count should be the current message count in the queue , but the getMessageCount is not that I think.


      When the producer and consumer work done , and disconnect from the server , the getMesageCount() method's result become to zero.


      What's the problem? How can I get the real message count in the queue?


      the producer thread code:

      Message m = session.createMessage(false);

             Producer p = session.createProducer("jms.queue.exampleQueue.p1");

             logger.info("session create");

             for (int i=0; i<1000;i++) {


                       m.putStringProperty("x", "vjsks_"+i);





      the consumer thread code:

      Consumer c = session.createConsumer("jms.queue.exampleQueue.p1");

             m = null;


             for (int i=0; i<10;){

                                 m = c.receive(1000);

                                 if (m != null) {



                                 } else i++;