We're happily using a Jboss 4.0 application server to host a JMS queue we use. Our actual use of the queue is straightforward, and is working very well.
As part of our monitoring strategy, we want to periodically (every minute or so) examine the queue to look at the oldest message, the youngest message and the number of messages in the queue.
The oldest one is easy - simply get a browser's enumeration and look at the first.
Is there a way to specify the messageSelector so as to get the queueBrowser to work in reverse order? That would make getting the youngest one easy too.
The JMX console seems to be easily able to get the QueueDepth. Do I simply cast the Queue object to a org.jboss.mq.server.jmx.Queue and then look for a queueDepth() method that returns an int?
The queue depth comes from an object that does not implement the javax.jms.Queue interface. So you can't cast it to that object to get the depth. What you want to do is get the MBeanServer and then look up the depth through JMX. Take a look at the Wiki.