1 Reply Latest reply on Aug 26, 2010 8:05 PM by gaohoward

    Negative MessageCount

    newway

      We have a part in my code that queries a queue once in an hour to get it's size.

       

      this is the code e used

       

      MBeanServer mBeanServer = MBeanServerLocator.locateJBoss();
       
      ObjectName serverObjectName = new ObjectName("jboss.messaging.destination:service=Queue,name=" + queueName);
      Integer messagesInQueue = (Integer) mBeanServer.getAttribute(serverObjectName, "MessageCount");
      return messagesInQueue.intValue() ;
      
      
      

       

      and we keep the data in the DB.

       

      from looking into the data kept we see that sometimes we receive negative values.

       

      in https://jira.jboss.org/browse/JBMESSAGING-926?focusedCommentId=12356514&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel We saw a discussion about this issue but it describes a scenario of calling removeAllMessage. In our case we don't interfere with the queues work messages are sent by the producer and handled by the receivers.

       

      we are using Messaging 1.4.5.GA

       

      I have 2 questions:

      1. Is there an explanation for the negative values?
      2. Can We trust the values given when they aren't negative?

       

      Thanks,

      Noa

        • 1. Re: Negative MessageCount
          gaohoward

          Yes it's possible to be negative.

           

          The reason for this is that the message delivering and acknowledging are synchronous. A messages is being delivered to a consumer in a thread and the counter is updated in another. The ack of message is obviously also asynchronous wrt delivering.  So their is a chance that a message ack comes bebore the counter is added.

           

          Howard