code: private boolean connect() {
          if (this.factory == null) {
              return false;
          }
          
          if (isConnected()) {
              return true;
          }
          
          try {
              this.connection = this.factory.createConnection();
              this.session = (TopicSession) this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              this.connection.start();
              return true;
          } catch (Exception e) {
              log.error("Error communicating with JMS server: " + e.getMessage());
              disconnect();
              return false;
          }
      }
docs: Connect to the JMS server.
  
  @return True if successful.