You may wish to raise an enhancement request for this. There is currently no way to block till some broker is discovered. I imagine the best that could be easily achieved is to have start() block till a broker is discovered, with some variable determining the length of the block before an exception is thrown.
At teh moment, there is no high level way get notified when a broker is discovered On 5 February 2010 19:58, kjones <[email protected]> wrote: > > 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. > > -- http://blog.garytully.com Open Source Integration http://fusesource.com
