What is the best way to go over a JMS queue and get all the messages in it?
How can count the number of messages in a queue?
Thanks.
Using JmsTemplate
public int getMessageCount(String messageSelector)
{
return jmsTemplate.browseSelected(messageSelector, new BrowserCallback<Integer>() {
@Override
public Integer doInJms(Session s, QueueBrowser qb) throws JMSException
{
return Collections.list(qb.getEnumeration()).size();
}
});
}