activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: catching exceptions on login
Date Tue, 06 Feb 2007 13:31:31 GMT
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...

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...

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 <> 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: Connection
> refused: connectjavax.jms.JMSException: Could not connect to broker URL:
> tcp://localhost:61616. Reason: Connection
> refused: connect
>         at
> org.apache.activemq.util.JMSExceptionSupport.create(
>         at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(
>         at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(
>         at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(
>         at
> My method is
>       public synchronized void onException(JMSException ex) {
>           System.out.println("JMS Exception occured.  Shutting down
> client.");
>       }
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at



View raw message