Using JmsTemplate
public int getMessageCount(String messageSelector)
{
return jmsTemplate.browseSelected(messageSelector, new BrowserCallback() {
@Override
public Integer doInJms(Session s, QueueBrowser qb) throws JMSException
{
return Collections.list(qb.getEnumeration()).size();
}
});
}