@Override
  protected void setUp() throws Exception {
    super.setUp();

    config = createBasicConfig();
    config
        .getConnectorConfigurations()
        .put("netty", new TransportConfiguration(NettyConnectorFactory.class.getName()));

    DiscoveryGroupConfiguration dcg =
        new DiscoveryGroupConfiguration("mygroup", "172.16.8.10", "243.7.7.7", 12345, 5432, 5432);
    config.getDiscoveryGroupConfigurations().put("mygroup", dcg);
    HornetQServer server = createServer(false, config);

    deploymentManager = new FileDeploymentManager(config.getFileDeployerScanPeriod());

    jmsServer = new JMSServerManagerImpl(server);
    context = new InVMContext();
    jmsServer.setContext(context);
    jmsServer.start();
  }
示例#2
0
  private void deployClusterConnection(final ClusterConnectionConfiguration config)
      throws Exception {
    if (config.getName() == null) {
      ClusterManagerImpl.log.warn(
          "Must specify a unique name for each cluster connection. This one will not be deployed.");

      return;
    }

    if (config.getAddress() == null) {
      ClusterManagerImpl.log.warn(
          "Must specify an address for each cluster connection. This one will not be deployed.");

      return;
    }

    TransportConfiguration connector =
        configuration.getConnectorConfigurations().get(config.getConnectorName());

    if (connector == null) {
      log.warn(
          "No connector with name '"
              + config.getConnectorName()
              + "'. The cluster connection will not be deployed.");
      return;
    }

    if (clusterConnections.containsKey(config.getName())) {
      log.warn(
          "Cluster Configuration  '"
              + config.getConnectorName()
              + "' already exists. The cluster connection will not be deployed.",
          new Exception("trace"));
      return;
    }

    ClusterConnectionImpl clusterConnection;

    if (config.getDiscoveryGroupName() != null) {
      DiscoveryGroupConfiguration dg =
          configuration.getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());

      if (dg == null) {
        ClusterManagerImpl.log.warn(
            "No discovery group with name '"
                + config.getDiscoveryGroupName()
                + "'. The cluster connection will not be deployed.");
        return;
      }

      if (log.isDebugEnabled()) {
        log.debug(
            this
                + " Starting a Discovery Group Cluster Connection, name="
                + config.getDiscoveryGroupName()
                + ", dg="
                + dg);
      }

      clusterConnection =
          new ClusterConnectionImpl(
              this,
              dg,
              connector,
              new SimpleString(config.getName()),
              new SimpleString(config.getAddress()),
              config.getMinLargeMessageSize(),
              config.getClientFailureCheckPeriod(),
              config.getConnectionTTL(),
              config.getRetryInterval(),
              config.getRetryIntervalMultiplier(),
              config.getMaxRetryInterval(),
              config.getReconnectAttempts(),
              config.getCallTimeout(),
              config.getCallFailoverTimeout(),
              config.isDuplicateDetection(),
              config.isForwardWhenNoConsumers(),
              config.getConfirmationWindowSize(),
              executorFactory,
              server,
              postOffice,
              managementService,
              scheduledExecutor,
              config.getMaxHops(),
              nodeUUID,
              backup,
              server.getConfiguration().getClusterUser(),
              server.getConfiguration().getClusterPassword(),
              config.isAllowDirectConnectionsOnly());
    } else {
      TransportConfiguration[] tcConfigs =
          config.getStaticConnectors() != null
              ? connectorNameListToArray(config.getStaticConnectors())
              : null;

      if (log.isDebugEnabled()) {
        log.debug(this + " defining cluster connection towards " + Arrays.toString(tcConfigs));
      }

      clusterConnection =
          new ClusterConnectionImpl(
              this,
              tcConfigs,
              connector,
              new SimpleString(config.getName()),
              new SimpleString(config.getAddress()),
              config.getMinLargeMessageSize(),
              config.getClientFailureCheckPeriod(),
              config.getConnectionTTL(),
              config.getRetryInterval(),
              config.getRetryIntervalMultiplier(),
              config.getMaxRetryInterval(),
              config.getReconnectAttempts(),
              config.getCallTimeout(),
              config.getCallFailoverTimeout(),
              config.isDuplicateDetection(),
              config.isForwardWhenNoConsumers(),
              config.getConfirmationWindowSize(),
              executorFactory,
              server,
              postOffice,
              managementService,
              scheduledExecutor,
              config.getMaxHops(),
              nodeUUID,
              backup,
              server.getConfiguration().getClusterUser(),
              server.getConfiguration().getClusterPassword(),
              config.isAllowDirectConnectionsOnly());
    }

    if (defaultClusterConnection == null) {
      defaultClusterConnection = clusterConnection;
    }

    managementService.registerCluster(clusterConnection, config);

    clusterConnections.put(config.getName(), clusterConnection);

    if (log.isDebugEnabled()) {
      log.debug("ClusterConnection.start at " + clusterConnection, new Exception("trace"));
    }
  }
示例#3
0
  public synchronized void deployBridge(final BridgeConfiguration config, final boolean start)
      throws Exception {
    if (config.getName() == null) {
      ClusterManagerImpl.log.warn(
          "Must specify a unique name for each bridge. This one will not be deployed.");

      return;
    }

    if (config.getQueueName() == null) {
      ClusterManagerImpl.log.warn(
          "Must specify a queue name for each bridge. This one will not be deployed.");

      return;
    }

    if (config.getForwardingAddress() == null) {
      ClusterManagerImpl.log.debug(
          "Forward address is not specified. Will use original message address instead");
    }

    if (bridges.containsKey(config.getName())) {
      ClusterManagerImpl.log.warn(
          "There is already a bridge with name "
              + config.getName()
              + " deployed. This one will not be deployed.");

      return;
    }

    Transformer transformer = instantiateTransformer(config.getTransformerClassName());

    Binding binding = postOffice.getBinding(new SimpleString(config.getQueueName()));

    if (binding == null) {
      ClusterManagerImpl.log.warn(
          "No queue found with name " + config.getQueueName() + " bridge will not be deployed.");

      return;
    }

    Queue queue = (Queue) binding.getBindable();

    ServerLocatorInternal serverLocator;

    if (config.getDiscoveryGroupName() != null) {
      DiscoveryGroupConfiguration discoveryGroupConfiguration =
          configuration.getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());
      if (discoveryGroupConfiguration == null) {
        ClusterManagerImpl.log.warn(
            "No discovery group configured with name '"
                + config.getDiscoveryGroupName()
                + "'. The bridge will not be deployed.");

        return;
      }

      if (config.isHA()) {
        serverLocator =
            (ServerLocatorInternal)
                HornetQClient.createServerLocatorWithHA(discoveryGroupConfiguration);
      } else {
        serverLocator =
            (ServerLocatorInternal)
                HornetQClient.createServerLocatorWithoutHA(discoveryGroupConfiguration);
      }

    } else {
      TransportConfiguration[] tcConfigs = connectorNameListToArray(config.getStaticConnectors());

      if (tcConfigs == null) {
        return;
      }

      if (config.isHA()) {
        serverLocator = (ServerLocatorInternal) HornetQClient.createServerLocatorWithHA(tcConfigs);
      } else {
        serverLocator =
            (ServerLocatorInternal) HornetQClient.createServerLocatorWithoutHA(tcConfigs);
      }
    }

    serverLocator.setConfirmationWindowSize(config.getConfirmationWindowSize());

    // We are going to manually retry on the bridge in case of failure
    serverLocator.setReconnectAttempts(0);
    serverLocator.setInitialConnectAttempts(-1);
    serverLocator.setRetryInterval(config.getRetryInterval());
    serverLocator.setMaxRetryInterval(config.getMaxRetryInterval());
    serverLocator.setRetryIntervalMultiplier(config.getRetryIntervalMultiplier());
    serverLocator.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod());
    serverLocator.setBlockOnDurableSend(!config.isUseDuplicateDetection());
    serverLocator.setBlockOnNonDurableSend(!config.isUseDuplicateDetection());
    serverLocator.setMinLargeMessageSize(config.getMinLargeMessageSize());
    // disable flow control
    serverLocator.setProducerWindowSize(-1);

    // This will be set to 30s unless it's changed from embedded / testing
    // there is no reason to exception the config for this timeout
    // since the Bridge is supposed to be non-blocking and fast
    // We may expose this if we find a good use case
    serverLocator.setCallTimeout(config.getCallTimeout());
    if (!config.isUseDuplicateDetection()) {
      log.debug(
          "Bridge "
              + config.getName()
              + " is configured to not use duplicate detecion, it will send messages synchronously");
    }

    clusterLocators.add(serverLocator);

    Bridge bridge =
        new BridgeImpl(
            serverLocator,
            config.getReconnectAttempts(),
            config.getRetryInterval(),
            config.getRetryIntervalMultiplier(),
            config.getMaxRetryInterval(),
            nodeUUID,
            new SimpleString(config.getName()),
            queue,
            executorFactory.getExecutor(),
            SimpleString.toSimpleString(config.getFilterString()),
            SimpleString.toSimpleString(config.getForwardingAddress()),
            scheduledExecutor,
            transformer,
            config.isUseDuplicateDetection(),
            config.getUser(),
            config.getPassword(),
            !backup,
            server.getStorageManager());

    bridges.put(config.getName(), bridge);

    managementService.registerBridge(bridge, config);

    if (start) {
      bridge.start();
    }
  }
示例#4
0
  private void deployClusterConnection(final ClusterConnectionConfiguration config)
      throws Exception {
    if (config.getName() == null) {
      HornetQServerLogger.LOGGER.clusterConnectionNotUnique();

      return;
    }

    if (config.getAddress() == null) {
      HornetQServerLogger.LOGGER.clusterConnectionNoForwardAddress();

      return;
    }

    TransportConfiguration connector =
        configuration.getConnectorConfigurations().get(config.getConnectorName());

    if (connector == null) {
      HornetQServerLogger.LOGGER.clusterConnectionNoConnector(config.getConnectorName());
      return;
    }

    if (clusterConnections.containsKey(config.getName())) {
      HornetQServerLogger.LOGGER.clusterConnectionAlreadyExists(config.getConnectorName());
      return;
    }

    ClusterConnectionImpl clusterConnection;
    DiscoveryGroupConfiguration dg;

    if (config.getDiscoveryGroupName() != null) {
      dg = configuration.getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());

      if (dg == null) {
        HornetQServerLogger.LOGGER.clusterConnectionNoDiscoveryGroup(
            config.getDiscoveryGroupName());
        return;
      }

      if (HornetQServerLogger.LOGGER.isDebugEnabled()) {
        HornetQServerLogger.LOGGER.debug(
            this
                + " Starting a Discovery Group Cluster Connection, name="
                + config.getDiscoveryGroupName()
                + ", dg="
                + dg);
      }

      clusterConnection =
          new ClusterConnectionImpl(
              this,
              dg,
              connector,
              new SimpleString(config.getName()),
              new SimpleString(config.getAddress()),
              config.getMinLargeMessageSize(),
              config.getClientFailureCheckPeriod(),
              config.getConnectionTTL(),
              config.getRetryInterval(),
              config.getRetryIntervalMultiplier(),
              config.getMaxRetryInterval(),
              config.getReconnectAttempts(),
              config.getCallTimeout(),
              config.getCallFailoverTimeout(),
              config.isDuplicateDetection(),
              config.isForwardWhenNoConsumers(),
              config.getConfirmationWindowSize(),
              executorFactory,
              threadPool,
              server,
              postOffice,
              managementService,
              scheduledExecutor,
              config.getMaxHops(),
              nodeManager,
              backup,
              server.getConfiguration().getClusterUser(),
              server.getConfiguration().getClusterPassword(),
              config.isAllowDirectConnectionsOnly(),
              config.getClusterNotificationInterval(),
              config.getClusterNotificationAttempts());
    } else {
      TransportConfiguration[] tcConfigs =
          config.getStaticConnectors() != null
              ? connectorNameListToArray(config.getStaticConnectors())
              : null;

      if (HornetQServerLogger.LOGGER.isDebugEnabled()) {
        HornetQServerLogger.LOGGER.debug(
            this + " defining cluster connection towards " + Arrays.toString(tcConfigs));
      }

      clusterConnection =
          new ClusterConnectionImpl(
              this,
              tcConfigs,
              connector,
              new SimpleString(config.getName()),
              new SimpleString(config.getAddress()),
              config.getMinLargeMessageSize(),
              config.getClientFailureCheckPeriod(),
              config.getConnectionTTL(),
              config.getRetryInterval(),
              config.getRetryIntervalMultiplier(),
              config.getMaxRetryInterval(),
              config.getReconnectAttempts(),
              config.getCallTimeout(),
              config.getCallFailoverTimeout(),
              config.isDuplicateDetection(),
              config.isForwardWhenNoConsumers(),
              config.getConfirmationWindowSize(),
              executorFactory,
              threadPool,
              server,
              postOffice,
              managementService,
              scheduledExecutor,
              config.getMaxHops(),
              nodeManager,
              backup,
              server.getConfiguration().getClusterUser(),
              server.getConfiguration().getClusterPassword(),
              config.isAllowDirectConnectionsOnly(),
              config.getClusterNotificationInterval(),
              config.getClusterNotificationAttempts());
    }

    if (defaultClusterConnection == null) {
      defaultClusterConnection = clusterConnection;
    }

    managementService.registerCluster(clusterConnection, config);

    clusterConnections.put(config.getName(), clusterConnection);

    if (HornetQServerLogger.LOGGER.isTraceEnabled()) {
      HornetQServerLogger.LOGGER.trace(
          "ClusterConnection.start at " + clusterConnection, new Exception("trace"));
    }
  }
示例#5
0
  public synchronized void deployBridge(final BridgeConfiguration config) throws Exception {
    if (config.getName() == null) {
      HornetQServerLogger.LOGGER.bridgeNotUnique();

      return;
    }

    if (config.getQueueName() == null) {
      HornetQServerLogger.LOGGER.bridgeNoQueue(config.getName());

      return;
    }

    if (config.getForwardingAddress() == null) {
      HornetQServerLogger.LOGGER.bridgeNoForwardAddress(config.getName());
    }

    if (bridges.containsKey(config.getName())) {
      HornetQServerLogger.LOGGER.bridgeAlreadyDeployed(config.getName());

      return;
    }

    Transformer transformer = instantiateTransformer(config.getTransformerClassName());

    Binding binding = postOffice.getBinding(new SimpleString(config.getQueueName()));

    if (binding == null) {
      HornetQServerLogger.LOGGER.bridgeQueueNotFound(config.getQueueName(), config.getName());

      return;
    }

    Queue queue = (Queue) binding.getBindable();

    ServerLocatorInternal serverLocator;

    if (config.getDiscoveryGroupName() != null) {
      DiscoveryGroupConfiguration discoveryGroupConfiguration =
          configuration.getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());
      if (discoveryGroupConfiguration == null) {
        HornetQServerLogger.LOGGER.bridgeNoDiscoveryGroup(config.getDiscoveryGroupName());

        return;
      }

      if (config.isHA()) {
        serverLocator =
            (ServerLocatorInternal)
                HornetQClient.createServerLocatorWithHA(discoveryGroupConfiguration);
      } else {
        serverLocator =
            (ServerLocatorInternal)
                HornetQClient.createServerLocatorWithoutHA(discoveryGroupConfiguration);
      }

    } else {
      TransportConfiguration[] tcConfigs = connectorNameListToArray(config.getStaticConnectors());

      if (tcConfigs == null) {
        HornetQServerLogger.LOGGER.bridgeCantFindConnectors(config.getName());
        return;
      }

      if (config.isHA()) {
        serverLocator = (ServerLocatorInternal) HornetQClient.createServerLocatorWithHA(tcConfigs);
      } else {
        serverLocator =
            (ServerLocatorInternal) HornetQClient.createServerLocatorWithoutHA(tcConfigs);
      }
    }

    if (config.getForwardingAddress() != null) {
      AddressSettings addressConfig =
          configuration.getAddressesSettings().get(config.getForwardingAddress());

      // The address config could be null on certain test cases or some Embedded environment
      if (addressConfig == null) {
        // We will certainly have this warning on testcases which is ok
        HornetQServerLogger.LOGGER.bridgeCantFindAddressConfig(
            config.getName(), config.getForwardingAddress());
      } else {
        final int windowSize = config.getConfirmationWindowSize();
        final long maxBytes = addressConfig.getMaxSizeBytes();

        if (maxBytes != -1 && maxBytes < windowSize) {
          HornetQServerLogger.LOGGER.bridgeConfirmationWindowTooSmall(
              config.getName(), config.getForwardingAddress(), windowSize, maxBytes);
        }
      }
    }

    serverLocator.setIdentity("Bridge " + config.getName());
    serverLocator.setConfirmationWindowSize(config.getConfirmationWindowSize());

    // We are going to manually retry on the bridge in case of failure
    serverLocator.setReconnectAttempts(0);
    serverLocator.setInitialConnectAttempts(0);
    serverLocator.setRetryInterval(config.getRetryInterval());
    serverLocator.setMaxRetryInterval(config.getMaxRetryInterval());
    serverLocator.setRetryIntervalMultiplier(config.getRetryIntervalMultiplier());
    serverLocator.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod());
    serverLocator.setConnectionTTL(config.getConnectionTTL());
    serverLocator.setBlockOnDurableSend(!config.isUseDuplicateDetection());
    serverLocator.setBlockOnNonDurableSend(!config.isUseDuplicateDetection());
    serverLocator.setMinLargeMessageSize(config.getMinLargeMessageSize());
    // disable flow control
    serverLocator.setProducerWindowSize(-1);

    // This will be set to 30s unless it's changed from embedded / testing
    // there is no reason to exception the config for this timeout
    // since the Bridge is supposed to be non-blocking and fast
    // We may expose this if we find a good use case
    serverLocator.setCallTimeout(config.getCallTimeout());
    if (!config.isUseDuplicateDetection()) {
      HornetQServerLogger.LOGGER.debug(
          "Bridge "
              + config.getName()
              + " is configured to not use duplicate detecion, it will send messages synchronously");
    }

    clusterLocators.add(serverLocator);

    Bridge bridge =
        new BridgeImpl(
            serverLocator,
            config.getReconnectAttempts(),
            config.getReconnectAttemptsOnSameNode(),
            config.getRetryInterval(),
            config.getRetryIntervalMultiplier(),
            config.getMaxRetryInterval(),
            nodeManager.getUUID(),
            new SimpleString(config.getName()),
            queue,
            executorFactory.getExecutor(),
            FilterImpl.createFilter(config.getFilterString()),
            SimpleString.toSimpleString(config.getForwardingAddress()),
            scheduledExecutor,
            transformer,
            config.isUseDuplicateDetection(),
            config.getUser(),
            config.getPassword(),
            !backup,
            server.getStorageManager());

    bridges.put(config.getName(), bridge);

    managementService.registerBridge(bridge, config);

    bridge.start();
  }