activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robd <rdrysd...@arantech.com>
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
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.


Mime
View raw message