activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khandelwalanuj <khandelwal.anu...@gmail.com>
Subject Queue Browser In ActiveMQ-5.10
Date Thu, 19 Feb 2015 07:08:25 GMT
Hi,

I am browsing queue messages periodically using below method: 

I have list of Queues and I am creating single session for all the browsers.
Is this the correct way of browsing or I should use create separate
connections/sessions  ? 


----------------
public Map<String, List&lt;GearMessage>> getQueueMessages() 
{
            Map<String, List&lt;GearMessage>> queueMessageMap = new
HashMap<String, List&lt;GearMessage>>();
            try {
                 Connection conn = connectionFactory.createConnection();
                 Session session = conn.createSession(true,
Session.AUTO_ACKNOWLEDGE);
                 conn.start();
                 for (Entry<String, Queue> entry : queueMap.entrySet()) {
                     List<GearMessage> messageList = new
ArrayList<GearMessage>();
                     String key = entry.getKey();
                     Queue queue = entry.getValue();
     
                     QueueBrowser browser = session.createBrowser(queue);
                     Enumeration e = browser.getEnumeration();
                     while (e.hasMoreElements()) {
                         Message msg = (Message) e.nextElement();
                         GearMessage gearMessage = messageParser.parse(msg);
                         messageList.add(gearMessage);
                     }
                     queueMessageMap.put(key, messageList);
                 }
                 conn.close();
0-----------

Thanks,
Anuj



--
View this message in context: http://activemq.2283324.n4.nabble.com/Queue-Browser-In-ActiveMQ-5-10-tp4691748.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message