Transport listner sounds good, do you have an example of this ?
James.Strachan wrote: > > What do you want to do if the broker is down? Let the user know about > it and keep waiting until a connection is established? > > The simplest solution today is to use auto-reconnect... > http://activemq.apache.org/how-can-i-support-auto-reconnection.html > > then the createConnection() method will block until a valid login > attempt is made (so you know if the login worked or not). > > You might wanna use a background thread to do the login to avoid > blocking the main thread. > > Then to let the user know of connection problems you can use the > transport listener... > http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQConnection.html#addTransportListener(org.apache.activemq.transport.TransportListener) > > > Another approach is just to catch the JMS exceptions and differentiate > between a login failure from a connection failure - maybe thats > simpler for you? > > On 2/6/07, miniman <[EMAIL PROTECTED]> wrote: >> >> All if i have a client which i want to catch an exception is the client >> is >> unable to connect. So if the activemq is down i still want the client to >> work but just display a message that the host is down. >> >> When i try >> >> // Create a Connection >> Connection connection = >> connectionFactory.createConnection(); >> connection.setExceptionListener(this); >> >> I get the exception but it does not come from my class >> >> Caught: javax.jms.JMSException: Could not connect to broker URL: >> tcp://localhost:61616. Reason: java.net.ConnectException: Connection >> refused: connectjavax.jms.JMSException: Could not connect to broker URL: >> tcp://localhost:61616. Reason: java.net.ConnectException: Connection >> refused: connect >> at >> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:33) >> at >> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:271) >> at >> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:211) >> at >> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:158) >> at >> com.db.abmonitor.client.dataimporter.TopicConsumer.run(TopicConsumer.java:40) >> >> My method is >> >> public synchronized void onException(JMSException ex) { >> System.out.println("JMS Exception occured. Shutting down >> client."); >> } >> -- >> View this message in context: >> http://www.nabble.com/catching-exceptions-on-login-tf3180552.html#a8825721 >> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >> >> > > > -- > > James > ------- > http://radio.weblogs.com/0112098/ > > -- View this message in context: http://www.nabble.com/catching-exceptions-on-login-tf3180552.html#a8825990 Sent from the ActiveMQ - User mailing list archive at Nabble.com.