I am using an ActiveMq embedded broker. I am using pub/sub model. I have multiple listeners subscribed to the topic. I am using Default Message listener container.
So I started getting statistics of the topic and the subscribers.
The statistic for number of messages in Topic is always zero.
DestinationStatistics statistics = destination
.getDestinationStatistics();
LOG.info("The message count in topic is" + destination.getMessages().count())
The 'message count in topic is' always zero, as far as I saw. So now I got the statistics for the consumers to the destination. The destination is topic I am using.
Iterator<Subscription> it = destination.getConsumers().iterator();
while(it.hasNext()){
Subscription s= it.next();
LOG.info(s.getPendingQueueSize()+ ""+ s.getEnqueueCounter()+""+s.getDequeueCounter())
}
I saw that these stats for each consumer reflect the messages I have sent as part of pub/sub.
So how does this whole process work?
I publish a message, the broker immediately pushes the message to the subscriber, the subscribers maintain the messages of their respective consumers. Hence the message count in topic is always zero and the stats for each consumer give an idea of the messages received by the broker.
Can someone explain the process and how the stats should work?