/** This will be called periodically by the Transaction Manager */
  public XAResource[] getXAResources() {
    try {
      checkFailures();

      HornetQXAResourceWrapper[] resourceArray = new HornetQXAResourceWrapper[recoveries.size()];
      resourceArray = recoveries.values().toArray(resourceArray);

      if (HornetQJMSServerLogger.LOGGER.isDebugEnabled()) {
        HornetQJMSServerLogger.LOGGER.debug(
            "\n=======================================================================================");
        HornetQJMSServerLogger.LOGGER.debug("Returning the following list on getXAREsources:");
        for (Map.Entry<String, HornetQXAResourceWrapper> entry : recoveries.entrySet()) {
          HornetQJMSServerLogger.LOGGER.debug(
              "server-id=" + entry.getKey() + ", value=" + entry.getValue());
        }
        HornetQJMSServerLogger.LOGGER.debug(
            "=======================================================================================\n");
      }

      return resourceArray;
    } catch (Throwable e) {
      HornetQJMSServerLogger.LOGGER.warn(e.getMessage(), e);
      return new XAResource[] {};
    }
  }
 /**
  * in case of a failure the Discovery will register itslef to retry
  *
  * @param failedDiscovery
  */
 public void failedDiscovery(RecoveryDiscovery failedDiscovery) {
   HornetQJMSServerLogger.LOGGER.debug(
       "RecoveryDiscovery being set to restart:" + failedDiscovery);
   synchronized (failedDiscoverySet) {
     failedDiscoverySet.add(failedDiscovery);
   }
 }
  /**
   * @param nodeID
   * @param networkConfiguration
   * @param username
   * @param password
   */
  public void nodeUp(
      String nodeID,
      Pair<TransportConfiguration, TransportConfiguration> networkConfiguration,
      String username,
      String password) {

    if (recoveries.get(nodeID) == null) {
      if (HornetQJMSServerLogger.LOGGER.isDebugEnabled()) {
        HornetQJMSServerLogger.LOGGER.debug(
            nodeID + " being registered towards " + networkConfiguration);
      }
      XARecoveryConfig config =
          new XARecoveryConfig(
              true, extractTransportConfiguration(networkConfiguration), username, password);

      HornetQXAResourceWrapper wrapper = new HornetQXAResourceWrapper(config);
      recoveries.putIfAbsent(nodeID, wrapper);
    }
  }
Example #4
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);
    }
  }