ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri.toString());
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue destination = session.createQueue(queueName);
QueueBrowser browser = session.createBrowser(destination);
List<Message> list = new ArrayList<Message>();
for (Enumeration<Message> enumn = browser.getEnumeration(); enumn.hasMoreElements();) {
list.add(enumn.nextElement());
}
messages = list.toArray();