activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bain <>
Subject Re: How to get number of unacknowledged messages on the broker?
Date Wed, 10 Jun 2015 13:14:11 GMT
If you have a topic with N subscribers, it sounds like enqueuing a message
will increase the first counter by 1, and having all consumers consume it
will increase the second counter by N, which is probably not what you want.

Also make sure your code to increment is threadsafe (in this case,
AtomicLong should be all you need), else you may find your counts off

I'd probably have approached it differently, using JMX to iterate over each
subscription for each topic and summing the number of unacknowledged
messages for each.  Note that because JMX is somewhat slow, the numbers
from my approach won't be exactly accurate (since message counts could
change after you get the stats for a subscriber but before you finish
collecting them all), so your approach will be more precise if you can find
the right place to put your first counter.

On Jun 10, 2015 4:50 AM, "xabhi" <> wrote:

> Hi,
> I want to get the number of unacknowledged messages on the broker. Below is
> the way I have implemented it currently. I am using BrokerPluginSupport
> which extends MutableBrokerFilter which has the send() and acknowledge()
> methods.
> 1. Keeping a counter which is increased in send() function -
> TotalSentMessages
> 2. Keeping a counter which is increased in acknowledge() function -
> TotalAckRecievedCount
> TotalUnackedMessages = TotalSentMessages - TotalAckRecievedCount
> I am getting this value close to 5.3 million which doesn't seem correct to
> me in my setup.
> I can't use BrokerView.getTotalMessageCount() as it reports only messages
> held on queue, nothing about topic subcsribers.
> Is there anything wrong in this method of calculating unacked messages? I
> believe that I am missing some thing here but not sure what?
> Thanks,
> Abhi
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message