• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Queue Depth - JMS

 
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.
 
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.
 
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!
 
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();

}
 
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
 
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.
 
Attractive, successful people love this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!