You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by robd <rd...@arantech.com> on 2007/09/20 19:36:58 UTC

ActiveMQQueueBrowser problem with not yet opened Connections

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
ActiveMQConnectionFactory();

	    connectionFactory.setBrokerURL("tcp://kittiwake:61616");

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

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

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


Possible prob is at line 166 of ActiveMQQueueBrowser  in release 4.1.1

if( browseDone.get() || !session.isRunning() ) {
                destroyConsumer();
                return false;
}
-- 
View this message in context: http://www.nabble.com/ActiveMQQueueBrowser-problem-with-not-yet-opened-Connections-tf4489009s2354.html#a12802140
Sent from the ActiveMQ - User mailing list archive at Nabble.com.