How to get the number of JMS posts in a thread

How do I get the number of JMS messages waiting for a particular JMS message subscriber to consume them? I use the topic model (publish / subscribe), not the queue model.

I want my MDB (message driven bean) to be able to determine this information about the topic that it is listening to. Be clear; I want my MDB to receive the number of messages waiting for a message.

I can not find information either on the Internet or in the documentation :(

I am using JBoss Messaging 1.4.4.

+4
source share
2 answers

AFAIK, JMS does not specify anything to count the number of messages in the recipient.

For this you need to use JMX. Check out the MBean attributes of the MBean topic in the documentation and / or java documentation TopicMBean # getMessageCounters () . The depth MessageCounter should be what you are looking for. But honestly, I do not know what you are going to do with this information, and if it makes sense for the topic. The message will remain in the subject if it has not been delivered to all subscribers, and each subscriber usually does not know their peers. So, how would one MDB interpret the number of messages?

Also note that I could not find this MBean in JBoss Messaging 2.0.0.alpha1 javadoc . I don’t know if it was deprecated (according to the code in 1.4, it isn’t) or if the documentation is not updated (after all, this is the javadoc alpha code and I could not find the link for beta4).

EDIT: As the scaffman noted, JBoss Messaging has been renamed HornetQ. It seems that there have been some changes in the API, but the concepts are still being applied. The documentation is here .

+4
source

You cannot, not with the JMS API. The JBossMessaging internal API can provide this information, but you will need to look through this documentation to find it.

0
source

All Articles