activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robd <>
Subject ActiveMQQueueBrowser problem with not yet opened Connections
Date Thu, 20 Sep 2007 17:36:58 GMT

There appears to be a problem browsing queues with ActiveMQQueueBrowser when
the connection is not
explicitly opened before creation of the Session.  This isn't in itself a
problem but it does cause problems when a pooled connection factory is used
as there isn't a guarantee of the connection being open at this stage.

Here's the code to replicate it.  You need messages in the queue first. 
Commenting out //connection.start(); will 

ActiveMQConnectionFactory connectionFactory = new


	    Connection connection = connectionFactory.createConnection();
	    Session session = connection.createSession(true,
	    int msgCount = 0;
		Queue queue = session.createQueue("UcpQueue");
		QueueBrowser browser = session.createBrowser(queue);
		ActiveMQQueueBrowser b;

		for (final Enumeration iter = browser.getEnumeration();
	         final Message message = (Message) iter.nextElement();
	         System.out.println("MessageID: " + message.getJMSMessageID());

		System.out.println("Count: " + msgCount);

Possible prob is at line 166 of ActiveMQQueueBrowser  in release 4.1.1

if( browseDone.get() || !session.isRunning() ) {
                return false;
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message