private synchronized void connect(){
  while (!connected && !shutdownRequested) {
    try {
      connection=jmsConnectionFactory.createConnection();
      refreshSubscriptions();
      connection.setExceptionListener(this);
      connection.start();
      connected=true;
    }
 catch (    Exception e) {
      LOGGER.error("Exception caught while trying to refresh the JMS connection; sleeping 5s before retrying.",e);
      try {
        Thread.sleep(SLEEP_BETWEEN_CONNECTION_ATTEMPTS);
      }
 catch (      InterruptedException interEx) {
        LOGGER.error("InterruptedException caught while waiting to reconnect.",interEx);
      }
    }
  }
  if (connected) {
    notifyConnectionListenerOnConnection();
  }
}

private synchronized void connect ( ) { while ( ! connected && ! shutdownRequested ) { try { connection = jmsConnectionFactory . createConnection ( ) ; refreshSubscriptions ( ) ; connection . setExceptionListener ( this ) ; connection . start ( ) ; connected = true ; } catch ( Exception e ) { LOGGER . error ( "Exception caught while trying to refresh the JMS connection; sleeping 5s before retrying." , e ) ; try { Thread . sleep ( SLEEP_BETWEEN_CONNECTION_ATTEMPTS ) ; } catch ( InterruptedException interEx ) { LOGGER . error ( "InterruptedException caught while waiting to reconnect." , interEx ) ; } } } if ( connected ) { notifyConnectionListenerOnConnection ( ) ; } }
runs until ( re ) connected . should only be called by one thread . use startreconnectthread to run in another thread ( only one thread will be started however many calls are made ) . < p > listeners are notified of connection once the connection is reestablished and all topic subscriptions are back .
