Пример #1
0
  public synchronized void start() throws Exception {
    synchronized (stoppingGuard) {
      stopping = false;
    }

    if (started) {
      HornetQJMSServerLogger.LOGGER.errorBridgeAlreadyStarted();
      return;
    }

    if (JMSBridgeImpl.trace) {
      HornetQJMSServerLogger.LOGGER.trace("Starting " + this);
    }

    // bridge has been stopped and is restarted
    if (executor.isShutdown()) {
      executor = createExecutor();
    }

    initPasswords();

    checkParams();

    TransactionManager tm = getTm();

    // There may already be a JTA transaction associated to the thread

    boolean ok;

    Transaction toResume = null;
    try {
      toResume = tm.suspend();

      ok = setupJMSObjects();
    } finally {
      if (toResume != null) {
        tm.resume(toResume);
      }
    }

    if (ok) {
      startSource();
    } else {
      HornetQJMSServerLogger.LOGGER.errorStartingBridge();
      handleFailureOnStartup();
    }
  }
Пример #2
0
  public JMSBridgeImpl(
      final ConnectionFactoryFactory sourceCff,
      final ConnectionFactoryFactory targetCff,
      final DestinationFactory sourceDestinationFactory,
      final DestinationFactory targetDestinationFactory,
      final String sourceUsername,
      final String sourcePassword,
      final String targetUsername,
      final String targetPassword,
      final String selector,
      final long failureRetryInterval,
      final int maxRetries,
      final QualityOfServiceMode qosMode,
      final int maxBatchSize,
      final long maxBatchTime,
      final String subName,
      final String clientID,
      final boolean addMessageIDInHeader,
      final MBeanServer mbeanServer,
      final String objectName) {
    this();

    this.sourceCff = sourceCff;

    this.targetCff = targetCff;

    this.sourceDestinationFactory = sourceDestinationFactory;

    this.targetDestinationFactory = targetDestinationFactory;

    this.sourceUsername = sourceUsername;

    this.sourcePassword = sourcePassword;

    this.targetUsername = targetUsername;

    this.targetPassword = targetPassword;

    this.selector = selector;

    this.failureRetryInterval = failureRetryInterval;

    this.maxRetries = maxRetries;

    qualityOfServiceMode = qosMode;

    this.maxBatchSize = maxBatchSize;

    this.maxBatchTime = maxBatchTime;

    this.subName = subName;

    this.clientID = clientID;

    this.addMessageIDInHeader = addMessageIDInHeader;

    checkParams();

    if (mbeanServer != null) {
      if (objectName != null) {
        this.mbeanServer = mbeanServer;

        try {
          JMSBridgeControlImpl controlBean = new JMSBridgeControlImpl(this);
          this.objectName = ObjectName.getInstance(objectName);
          StandardMBean mbean = new StandardMBean(controlBean, JMSBridgeControl.class);
          mbeanServer.registerMBean(mbean, this.objectName);
          HornetQJMSServerLogger.LOGGER.debug(
              "Registered JMSBridge instance as: " + this.objectName.getCanonicalName());
        } catch (Exception e) {
          throw new IllegalStateException("Failed to register JMSBridge MBean", e);
        }
      } else {
        throw new IllegalArgumentException("objectName is required when specifying an MBeanServer");
      }
    }

    if (JMSBridgeImpl.trace) {
      HornetQJMSServerLogger.LOGGER.trace("Created " + this);
    }
  }