コード例 #1
0
  protected JBossConnection createConnectionInternal(
      final String username, final String password, final boolean isXA, final int type)
      throws JMSException {
    if (sessionFactory == null) {
      // It doesn't matter if more than one is created due to a race
      sessionFactory =
          new ClientSessionFactoryImpl(
              connectorConfig,
              backupConnectorConfig,
              pingPeriod,
              callTimeout,
              consumerWindowSize,
              consumerMaxRate,
              producerWindowSize,
              producerMaxRate,
              blockOnAcknowledge,
              blockOnNonPersistentSend,
              blockOnPersistentSend,
              autoGroupId);
    }

    if (username != null) {
      // Since core has no connection concept, we need to create a session in order to authenticate
      // at this time

      ClientSession sess = null;

      try {
        sess = sessionFactory.createSession(username, password, false, false, false, false);
      } catch (MessagingException e) {
        throw JMSExceptionHelper.convertFromMessagingException(e);
      } finally {
        if (sess != null) {
          try {
            sess.close();
          } catch (Throwable ignore) {
          }
        }
      }
    }

    return new JBossConnection(username, password, type, clientID, dupsOKBatchSize, sessionFactory);
  }