code: private void reconnectAfter(final long timeInMillis) {
      new Thread() {
        @Override
        public void run() {
          LOGGER.info("Schedule reconnect after {} millis", timeInMillis);
          try {
            Thread.sleep(timeInMillis);
          }
          catch (InterruptedException e) {
          }
  
          int attempt = 0;
          while (session == null || session.getSessionState().equals(SessionState.CLOSED)) {
            try {
              LOGGER.info("Reconnecting attempt #{} ...", ++attempt);
              session = newSession();
            }
            catch (IOException e) {
              LOGGER.error("Failed opening connection and bind to " + remoteIpAddress + ":" + remotePort, e);
              // wait for a second
              try {
                Thread.sleep(1000);
              }
              catch (InterruptedException ee) {
              }
            }
          }
        }
      }.start();
    }
docs: Reconnect session after specified interval.
  
  @param timeInMillis is the interval.