5
votes

I found the following link to read messages from JMS Queue and its working.

https://blogs.oracle.com/soaproactive/entry/jms_step_3_using_the

Now I want to read JMS queue statistics programmatically like number of messages, number of pending messages and message in/out time etc. Is it possible in weblogic or weblogic provide any API for this purpose?

Please help.

3

3 Answers

5
votes

Statistics are part of a message broker implementation and thus vendor-specific. One popular implementations is ActiveMQ. It can be run in WebLogic Server or WebLogic Express.

Note: There are obviously many other JMS implementations around, and you should carefully evaluate for yourself which implementation suits your needs. Nevertheless, I shall use it as an example to point out the relevant features for your case:

Beginning with version 5.3, ActiveMQ ships with a statistics plugin

that can be used to retrieve statistics from the broker or its destinations.

You should be able to actively poll statistics from within your code by sending messages to specific destinations within the broker, see linked documentation for details.

Another feature of ActiveMQ is Advisory messages. Enable it in your broker's configuration and it

allows you to watch the system using regular JMS messages.

In this way, you can passively react to certain events in the messaging system , e.g. when a queue exceeds some threshold.

3
votes

There is no API for statistics in JMS spec. However you can use JMX to monitor the statistics.

From docs,

Monitoring JMS Servers

You can monitor statistics on active JMS servers defined in your domain via the Administration Console or through the JMSServerRuntimeMBean. JMS servers act as management containers for JMS queue and topic resources within JMS modules that are specifically targeted to JMS servers.

This post (new way) may be helpful.

2
votes

JMS API doesn't provide such information. It serves to receive and send messages, but isn't to grab statistics from underlying middleware.

Check direct API of the underlying MQ which you use. For instance, IBM WebSphere MQ has such API.