Q

How do I find out how many messages are in a JMS queue?

How do I find out how many messages are in a JMS queue? In MQ I would have used MQQueue.getCurrentDepth(), but...

there does not seem to be an equivalent in JMS.  

In JMS, the only portable solution to determine the number of messages in a queue is to create a javax.jms.QueueBrowser object. With the QueueBrowser, you can enumerate and count the messages in the queue, without consuming the messages.

This works well if the queue is rather small (up to 100 messages maybe), but can be very time consuming if there are many messages in the queue.

A JMS provider can offer administration APIs that allow you to obtain the number of message in a queue, in a more efficient manner. But these are vendor proprietary extensions and limit the portability of your JMS application.


 

This was last published in February 2002

Dig Deeper on Enterprise Application Integration (EAI)

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close