I added a browse() method to Messenger and implemented it in
MessengerSupport. I use it mostly for testing. It requires a few
additional methods to MessengerSupport
MessengerSupport changes:
public Enumeration browse(Destination destination) throws JMSException {
Session session = borrowSession();
QueueBrowser browser = null;
try {
browser = borrowMessageBrowser(session, destination);
return browser.getEnumeration();
} finally {
returnSession(session);
}
}
##########Followed format of Message Producer / Message Consumer to allow
caching someday##########
/** @return a QueueBrowser for the given session and destination */
protected QueueBrowser borrowMessageBrowser(
Session session,
Destination destination)
throws JMSException {
return createQueueBrowser(session, destination);
}
############################################################################################
/** @return a new QueueBrowser for the given session and destination */
protected QueueBrowser createQueueBrowser(
Session session,
Destination destination)
throws JMSException {
if (isTopic(session)) {
return null;
} else {
QueueSession queueSession = (QueueSession) session;
return queueSession.createBrowser((Queue) destination);
}
}