[jboss-user] [JBoss Messaging] - Re: Monitoring the depth of a Queue/Topic

timfox do-not-reply at jboss.com
Thu Feb 22 08:56:35 EST 2007


"jurivrljicak" wrote : this way?
  | 
  | QueueBrowser browser = s.createBrowser(queue);
  |   	int depth= getDepth(browser);
  | 
  | private int getDepth(QueueBrowser browser) throws JMSException {
  | 	int i=0;    	
  |     for(Enumeration e = browser.getEnumeration(); e.hasMoreElements(); ){
  |        i++;	
  |        e.nextElement();
  |     }
  | 	return i;
  | }
  | 
  | javax.jms api

This would probably be horribly slow - I wouldn't recommend it.

Also browsers are not mandated to provide a static snapshot of the queue, so the result won't necessarily exactly reflect the number of messages in the queue at any particular time.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020573#4020573

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020573



More information about the jboss-user mailing list