activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kjones <kjo...@safe.com>
Subject Broker discovery when no brokers exist still returns a connection factory which cannot be used.
Date Fri, 05 Feb 2010 19:58:20 GMT

I'm using ActiveMQ 5.3.0 with a single broker running as a stand-alone app
(not 
embedded).

I have a client consumer app with the following code which finds the broker 
through multicast discovery, obtains a connection to it and a session on it:


ActiveMQConnectionFactory connectionFactory = new 
   
ActiveMQConnectionFactory("discovery:multicast://default?group=myMessageBroker");

ActiveMQConnection msgBrokerConnection =
(ActiveMQConnection)connectionFactory.createConnection();

Session msgBrokerSession = msgBrokerConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);


When the broker is running, the above code successfully discovers the
broker, 
gets a connection to it and a session on it.

However, when the broker is not running, the same code still returns an 
ActiveMQConnectionFactory and a connection to a non-existent broker. The 
subsequent attempt to create a session on this connection fails.

I would ideally like to have the ActiveMQConnectionFactory return null or
throw 
an exception if no brokers are discovered.

Is there a way to determine when no brokers are discovered?

Any thoughts are appreciated.
-- 
View this message in context: http://old.nabble.com/Broker-discovery-when-no-brokers-exist-still-returns-a-connection-factory-which-cannot-be-used.-tp27473153p27473153.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message