This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Queue Depth - JMS  RSS feed

 
vaka suresh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there any way by which we can find Number of messages available in the Queue at a given point of time Programatically.
 
Steve Wink
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vaka suresh:
Hi,
Is there any way by which we can find Number of messages available in the Queue at a given point of time Programatically.


This is a notable omission from the JMS spec. You can get the depth by browsing every message in the queue, but obviously this is pretty wasteful. Some of the underlying queueing systems ( e.g. WebSphere MQ ) have APIs for getting depths if you can write a plug-in for your system.
 
Trimoorthy Kotte
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trimoorthy
 
Trimoorthy Kotte
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies, I missed out the text last time I was posting the reply. if you are using WebLogic Aplication server, you can access JMS MBeans through weblogic Mbean API for finding out the JMS queue depth. You might have similar APIs available in other app servers .

cheers!
 
Babu Rengarajan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code would list all the Queue(s) and their Queue depth in Websphere

try
{
ConfigService configService = ConfigServiceFactory.getConfigService();
javax.management.ObjectName on = new javax.management.ObjectName("WebSphere:*");
AdminService service =com.ibm.websphere.management.AdminServiceFactory.getAdminService();
Set objectNameSet= service.queryNames(on, null);
Iterator i = objectNameSet.iterator();
while(i.hasNext())
{
on = (ObjectName)i.next();
String type = on.getKeyProperty("type");
if("SIBQueuePoint".equals(type))
{

Object object = service.getAttribute(on , "depth");
System.out.println(" The Queue is : " + on.getKeyProperty("name") + " Number of messages is : " + ((Long)object).longValue());


}
}

}
catch(Exception err)
{

err.printStackTrace();

}
 
ashish zan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried way of getting queue depth, it works locally where no user name and password is given on was server. When i applied this program for production was server where user name and password has been given. It is given authentication problem. like administer, monitor
 
Joe Hepp
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is how we do the browsing method to get a count via JMS.



BTW, numOnQueue is defined outside this snippet of code.

It is wasteful but this is used in a batch retry situation so we aren't concerned with performance.

This functionality (the retry mechanism) used to be done via the base MQ Java API but we switched over to JMS as it handles property manipulation much better and we like the configuration simplification when using JMS. The queue depth issue was the only thing we found missing from the JMS API that was in the base MQ Java API.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!