2 Replies Latest reply on Jun 29, 2011 10:27 AM by clebert.suconic

    a problem of the message number in the queue

    oliverer

      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

      countMessage:578

      [{"timestamp":1309329696560,"messageID":2147492643,"expiration":0,"address":"jms.queue.exampleQueue.p1","priority":4,"durable":false,"type":0,"x":"vjsks_574"},{"timestamp":1309329696560,"messageID":2147492646,"expiration":0,"address":"jms.queue.exampleQueue.p1","priority":4,"durable":false,"type":0,"x":"vjsks_575"},{"timestamp":1309329696560,"messageID":2147492649,"expiration":0,"address":"jms.queue.exampleQueue.p1","priority":4,"durable":false,"type":0,"x":"vjsks_576"},{"timestamp":1309329696560,"messageID":2147492652,"expiration":0,"address":"jms.queue.exampleQueue.p1","priority":4,"durable":false,"type":0,"x":"vjsks_577"}]

       

       

      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);

                       p.send(m);

                       Thread.sleep(1000);

             }

       

      the consumer thread code:

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

             m = null;

             session.start();

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

                                 m = c.receive(1000);

                                 if (m != null) {

                                           logger.info(m.getStringProperty("x"));

                                           m.acknowledge();

                                 } else i++;

                                 Thread.sleep(1000);

                       logger.info("message:"+m);

             }