@Override
  protected void createConfigs() throws Exception {
    Configuration config1 = super.createDefaultConfig();
    config1.setBindingsDirectory(config1.getBindingsDirectory() + "_backup");
    config1.setJournalDirectory(config1.getJournalDirectory() + "_backup");
    config1.getAcceptorConfigurations().clear();
    config1.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(false));
    config1.setSecurityEnabled(false);
    config1.setSharedStore(false);
    config1.setBackup(true);
    server1Service = super.createServer(true, config1);

    Configuration config0 = super.createDefaultConfig();
    config0.getAcceptorConfigurations().clear();
    config0.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));

    config0.getConnectorConfigurations().put("toBackup", getConnectorTransportConfiguration(false));
    config0.setBackupConnectorName("toBackup");
    config0.setSecurityEnabled(false);
    config0.setSharedStore(false);
    server0Service = super.createServer(true, config0);

    server1Service.start();
    server0Service.start();
  }
Ejemplo n.º 2
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    // Start the servers
    Configuration conf0 = createBasicConfig();
    conf0.setJournalDirectory(getJournalDir(0, false));
    conf0.setBindingsDirectory(getBindingsDir(0, false));
    conf0.setSecurityEnabled(false);
    conf0.getAcceptorConfigurations().add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    server0 = addServer(HornetQServers.newHornetQServer(conf0, false));

    context0 = new InVMNamingContext();
    jmsServer0 = new JMSServerManagerImpl(server0);
    jmsServer0.setContext(context0);
    jmsServer0.start();

    Configuration conf1 = createBasicConfig();
    conf1.setSecurityEnabled(false);
    conf1.setJournalDirectory(getJournalDir(1, false));
    conf1.setBindingsDirectory(getBindingsDir(1, false));
    params1 = new HashMap<String, Object>();
    params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
    conf1
        .getAcceptorConfigurations()
        .add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));

    server1 = addServer(HornetQServers.newHornetQServer(conf1, false));

    context1 = new InVMNamingContext();

    jmsServer1 = new JMSServerManagerImpl(server1);
    jmsServer1.setContext(context1);
    jmsServer1.start();

    createQueue("sourceQueue", 0);

    jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");

    createQueue("localTargetQueue", 0);

    createQueue("targetQueue", 1);

    setUpAdministeredObjects();
    TxControl.enable();
    // We need a local transaction and recovery manager
    // We must start this after the remote servers have been created or it won't
    // have deleted the database and the recovery manager may attempt to recover transactions

  }
Ejemplo n.º 3
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    configuration = createDefaultConfig();
    configuration.setSecurityEnabled(false);
    server = createServer(true, configuration);
    // start the server
    server.start();

    qs = new AddressSettings();
    qs.setLastValueQueue(true);
    server.getAddressSettingsRepository().addMatch(address.toString(), qs);
    // then we create a client as normal
    locator =
        HornetQClient.createServerLocatorWithoutHA(
            new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));

    locator.setBlockOnAcknowledge(true);
    locator.setAckBatchSize(0);
    ClientSessionFactory sessionFactory = createSessionFactory(locator);
    clientSession = sessionFactory.createSession(false, true, true);
    clientSessionXa = sessionFactory.createSession(true, false, false);
    clientSession.createQueue(address, qName1, null, true);
  }
  protected void createLiveConfig(NodeManager nodeManager, int liveNode, int... otherLiveNodes)
      throws Exception {
    TransportConfiguration liveConnector =
        createTransportConfiguration(isNetty(), false, generateParams(liveNode, isNetty()));
    Configuration config0 = super.createDefaultConfig();
    config0.getAcceptorConfigurations().clear();
    config0
        .getAcceptorConfigurations()
        .add(createTransportConfiguration(isNetty(), true, generateParams(liveNode, isNetty())));
    config0.setSecurityEnabled(false);
    config0.setSharedStore(true);
    List<String> pairs = new ArrayList<String>();
    for (int node : otherLiveNodes) {
      TransportConfiguration otherLiveConnector =
          createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
      config0.getConnectorConfigurations().put(otherLiveConnector.getName(), otherLiveConnector);
      pairs.add(otherLiveConnector.getName());
    }
    basicClusterConnectionConfig(config0, liveConnector.getName(), pairs);
    config0.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);

    config0.setBindingsDirectory(config0.getBindingsDirectory() + "_" + liveNode);
    config0.setJournalDirectory(config0.getJournalDirectory() + "_" + liveNode);
    config0.setPagingDirectory(config0.getPagingDirectory() + "_" + liveNode);
    config0.setLargeMessagesDirectory(config0.getLargeMessagesDirectory() + "_" + liveNode);

    servers.put(
        liveNode,
        new SameProcessHornetQServer(
            createInVMFailoverServer(true, config0, nodeManager, liveNode)));
  }
Ejemplo n.º 5
0
  protected void createReplicatedConfigs() throws Exception {
    nodeManager = new InVMNodeManager();

    final TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
    final TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    final TransportConfiguration backupAcceptor = getAcceptorTransportConfiguration(false);

    nodeManager = new InVMNodeManager();
    backupConfig = createDefaultConfig();
    liveConfig = createDefaultConfig();

    ReplicatedBackupUtils.configureReplicationPair(
        backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector);

    final String sufix = "_backup";
    backupConfig.setBindingsDirectory(backupConfig.getBindingsDirectory() + sufix);
    backupConfig.setJournalDirectory(backupConfig.getJournalDirectory() + sufix);
    backupConfig.setPagingDirectory(backupConfig.getPagingDirectory() + sufix);
    backupConfig.setLargeMessagesDirectory(backupConfig.getLargeMessagesDirectory() + sufix);
    backupConfig.setSecurityEnabled(false);

    backupServer = createTestableServer(backupConfig);
    liveConfig.getAcceptorConfigurations().clear();
    liveConfig.getAcceptorConfigurations().add(getAcceptorTransportConfiguration(true));

    liveServer = createTestableServer(liveConfig);
  }
Ejemplo n.º 6
0
  protected static Configuration createDefaultConfig(
      final Map<String, Object> params, final String... acceptors) {
    Configuration configuration = new ConfigurationImpl();
    configuration.setSecurityEnabled(false);
    configuration.setJMXManagementEnabled(false);
    configuration.setBindingsDirectory(getBindingsDir());
    configuration.setJournalMinFiles(2);
    configuration.setJournalDirectory(getJournalDir());
    configuration.setJournalFileSize(100 * 1024);
    configuration.setPagingDirectory(getPageDir());
    configuration.setLargeMessagesDirectory(getLargeMessagesDir());
    configuration.setJournalCompactMinFiles(0);
    configuration.setJournalCompactPercentage(0);

    configuration.setFileDeploymentEnabled(false);

    configuration.setJournalType(getDefaultJournalType());

    configuration.getAcceptorConfigurations().clear();

    for (String acceptor : acceptors) {
      TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
      configuration.getAcceptorConfigurations().add(transportConfig);
    }

    return configuration;
  }
Ejemplo n.º 7
0
 private void configureAcceptor() {
   config.setPersistenceEnabled(true);
   config.setSecurityEnabled(false);
   config
       .getAcceptorConfigurations()
       .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
   config
       .getConnectorConfigurations()
       .put("connector", new TransportConfiguration(InVMConnectorFactory.class.getName()));
 }
  @BeforeClass
  public static void setup() throws Exception {
    Configuration configuration = new ConfigurationImpl();
    configuration.setPersistenceEnabled(false);
    configuration.setSecurityEnabled(false);
    configuration
        .getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));

    server = HornetQServers.newHornetQServer(configuration);
    server.start();
  }
Ejemplo n.º 9
0
  /** @throws Exception */
  protected void initServer() throws Exception {
    configuration = createDefaultConfig();
    configuration.setSecurityEnabled(false);
    configuration.setJournalMinFiles(2);
    server = createServer(true, configuration);
    server.start();

    AddressSettings qs = server.getAddressSettingsRepository().getMatch("*");
    AddressSettings newSets = new AddressSettings();
    newSets.setRedeliveryDelay(DelayedMessageTest.DELAY);
    newSets.merge(qs);
    server.getAddressSettingsRepository().addMatch(qName, newSets);
    locator = createInVMNonHALocator();
  }
Ejemplo n.º 10
0
  /**
   * @param toOtherServerPair
   * @throws Exception
   */
  private void setupServer1() throws Exception {
    List<String> toOtherServerPair = new ArrayList<String>();
    toOtherServerPair.add("toServer2");

    Configuration conf1 =
        createDefaultConfig(0, generateInVMParams(0), InVMAcceptorFactory.class.getCanonicalName());

    conf1.setSecurityEnabled(false);
    conf1.setJMXManagementEnabled(true);
    conf1.setPersistenceEnabled(false);

    conf1
        .getConnectorConfigurations()
        .put(
            "toServer2",
            new TransportConfiguration(
                InVMConnectorFactory.class.getName(), generateInVMParams(1)));
    conf1
        .getConnectorConfigurations()
        .put(
            "server1",
            new TransportConfiguration(
                InVMConnectorFactory.class.getName(), generateInVMParams(0)));

    conf1.setClustered(true);

    conf1
        .getClusterConfigurations()
        .add(
            new ClusterConnectionConfiguration(
                "to-server2",
                "jms",
                "server1",
                1000,
                true,
                true,
                MAX_HOPS,
                1024,
                toOtherServerPair,
                false));

    JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl();
    // jmsconfig.getTopicConfigurations().add(new TopicConfigurationImpl("t1", "topic/t1"));

    server1 = HornetQServers.newHornetQServer(conf1, false);
    jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig);
    context1 = new InVMContext();
    jmsServer1.setContext(context1);
  }
Ejemplo n.º 11
0
  private JMSServerManager createJMSServer() throws Exception {
    Configuration conf = createDefaultConfig();
    conf.setSecurityEnabled(false);
    conf.setJMXManagementEnabled(true);
    conf.setPersistenceEnabled(true);
    conf.setJournalType(JournalType.NIO);
    conf.getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    HornetQServer server = HornetQServers.newHornetQServer(conf, mbeanServer);

    context = new InVMContext();

    serverManager = new JMSServerManagerImpl(server);
    serverManager.setContext(context);
    return serverManager;
  }
  protected void createBackupConfig(
      NodeManager nodeManager,
      int liveNode,
      int nodeid,
      boolean createClusterConnections,
      int[] otherBackupNodes,
      int... otherClusterNodes)
      throws Exception {
    Configuration config1 = super.createDefaultConfig();
    config1.getAcceptorConfigurations().clear();
    config1
        .getAcceptorConfigurations()
        .add(createTransportConfiguration(isNetty(), true, generateParams(nodeid, isNetty())));
    config1.setSecurityEnabled(false);
    config1.setSharedStore(true);
    config1.setBackup(true);

    List<String> staticConnectors = new ArrayList<String>();
    for (int node : otherBackupNodes) {
      TransportConfiguration liveConnector =
          createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
      config1.getConnectorConfigurations().put(liveConnector.getName(), liveConnector);
      staticConnectors.add(liveConnector.getName());
    }
    TransportConfiguration backupConnector =
        createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty()));
    config1.getConnectorConfigurations().put(backupConnector.getName(), backupConnector);

    List<String> clusterNodes = new ArrayList<String>();
    for (int node : otherClusterNodes) {
      TransportConfiguration connector =
          createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
      config1.getConnectorConfigurations().put(connector.getName(), connector);
      clusterNodes.add(connector.getName());
    }
    basicClusterConnectionConfig(config1, backupConnector.getName(), clusterNodes);
    config1.setBindingsDirectory(config1.getBindingsDirectory() + "_" + liveNode);
    config1.setJournalDirectory(config1.getJournalDirectory() + "_" + liveNode);
    config1.setPagingDirectory(config1.getPagingDirectory() + "_" + liveNode);
    config1.setLargeMessagesDirectory(config1.getLargeMessagesDirectory() + "_" + liveNode);

    servers.put(
        nodeid,
        new SameProcessHornetQServer(
            createInVMFailoverServer(true, config1, nodeManager, liveNode)));
  }
  /** @throws Exception */
  protected void startServer() throws Exception {
    Configuration conf = createDefaultConfig(false);
    conf.getConnectorConfigurations()
        .put("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    conf.setSecurityEnabled(false);
    conf.setJMXManagementEnabled(true);
    conf.getAcceptorConfigurations().add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    server = HornetQServers.newHornetQServer(conf, mbeanServer, true);
    server.start();

    serverManager = new JMSServerManagerImpl(server);
    serverManager.start();

    ctx = new InVMNamingContext();

    serverManager.setContext(ctx);
    serverManager.activated();
  }
Ejemplo n.º 14
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    Configuration conf = createDefaultConfig();
    conf.setSecurityEnabled(false);
    conf.getAcceptorConfigurations().add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
    server = createServer(false, conf);
    jmsServer = new JMSServerManagerImpl(server);
    jmsServer.setContext(new NullInitialContext());
    jmsServer.start();

    cf1 =
        HornetQJMSClient.createConnectionFactoryWithoutHA(
            JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
    cf2 =
        HornetQJMSClient.createConnectionFactoryWithoutHA(
            JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    Map<String, Object> params = new HashMap<String, Object>();
    // params.put(RandomUtil.randomString(), RandomUtil.randomBoolean());
    connectorConfig =
        new TransportConfiguration(
            InVMConnectorFactory.class.getName(), params, RandomUtil.randomString());

    conf = createDefaultConfig(false);
    conf.setSecurityEnabled(false);
    conf.setJMXManagementEnabled(true);
    conf.getAcceptorConfigurations().clear();
    conf.getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    server = HornetQServers.newHornetQServer(conf, mbeanServer, true);
    conf.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig);
    server.start();
  }
Ejemplo n.º 16
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    Configuration conf = createBasicConfig();
    conf.setSecurityEnabled(false);
    conf.setJMXManagementEnabled(true);
    conf.getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    server = createServer(false, conf, mbeanServer);
    server.start();

    locator = createInVMNonHALocator();
    locator.setBlockOnNonDurableSend(true);
    locator.setBlockOnNonDurableSend(true);
    sf = createSessionFactory(locator);
    session = sf.createSession(false, true, false);
    session.start();
    addClientSession(session);
  }
Ejemplo n.º 17
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    Configuration config = createBasicConfig();
    config.setFileDeploymentEnabled(false);
    config.setSecurityEnabled(false);
    config
        .getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    InVMContext context = new InVMContext();
    jmsServer = new JMSServerManagerImpl(HornetQServers.newHornetQServer(config, false));
    jmsServer.setContext(context);
    jmsServer.start();

    jmsServer.createQueue(
        false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);
    jmsServer.createQueue(
        false, JMSBridgeImplTest.TARGET, null, true, "/queue/" + JMSBridgeImplTest.TARGET);
  }
Ejemplo n.º 18
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    Configuration conf = new ConfigurationImpl();
    conf.setSecurityEnabled(false);
    conf.setJMXManagementEnabled(true);
    conf.getAcceptorConfigurations()
        .add(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
    server = HornetQServers.newHornetQServer(conf, false);
    server.start();

    serverManager = new JMSServerManagerImpl(server);
    initialContext = new InVMContext();
    serverManager.setContext(initialContext);
    serverManager.start();
    serverManager.activated();

    serverManager.createTopic(topicName, topicName);
    registerConnectionFactory();
  }
Ejemplo n.º 19
0
  /** @throws Exception */
  protected void startServers() throws Exception {
    NodeManager nodeManager = new InVMNodeManager(false);
    backuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
    livetc = new TransportConfiguration(INVM_CONNECTOR_FACTORY);

    liveAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);

    backupAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams);

    backupConf = createBasicConfig(0);

    backupConf.getAcceptorConfigurations().add(backupAcceptortc);
    backupConf.getConnectorConfigurations().put(livetc.getName(), livetc);
    backupConf.getConnectorConfigurations().put(backuptc.getName(), backuptc);
    basicClusterConnectionConfig(backupConf, backuptc.getName(), livetc.getName());

    backupConf.setSecurityEnabled(false);
    backupConf.setJournalType(getDefaultJournalType());
    backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
    backupConf
        .getAcceptorConfigurations()
        .add(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams));
    backupConf.setBackup(true);
    backupConf.setSharedStore(true);
    backupConf.setBindingsDirectory(getBindingsDir());
    backupConf.setJournalMinFiles(2);
    backupConf.setJournalDirectory(getJournalDir());
    backupConf.setPagingDirectory(getPageDir());
    backupConf.setLargeMessagesDirectory(getLargeMessagesDir());
    backupConf.setPersistenceEnabled(true);
    backupService = new InVMNodeManagerServer(backupConf, nodeManager);

    backupJMSService = new JMSServerManagerImpl(backupService);

    backupJMSService.setContext(ctx2);

    backupJMSService.getHornetQServer().setIdentity("JMSBackup");
    log.info("Starting backup");
    backupJMSService.start();

    liveConf = createBasicConfig(0);

    liveConf.setJournalDirectory(getJournalDir());
    liveConf.setBindingsDirectory(getBindingsDir());

    liveConf.setSecurityEnabled(false);
    liveConf.getAcceptorConfigurations().add(liveAcceptortc);
    basicClusterConnectionConfig(liveConf, livetc.getName());
    liveConf.setSharedStore(true);
    liveConf.setJournalType(getDefaultJournalType());
    liveConf.setBindingsDirectory(getBindingsDir());
    liveConf.setJournalMinFiles(2);
    liveConf.setJournalDirectory(getJournalDir());
    liveConf.setPagingDirectory(getPageDir());
    liveConf.setLargeMessagesDirectory(getLargeMessagesDir());
    liveConf.getConnectorConfigurations().put(livetc.getName(), livetc);
    liveConf.setPersistenceEnabled(true);
    liveService = new InVMNodeManagerServer(liveConf, nodeManager);

    liveJMSService = new JMSServerManagerImpl(liveService);

    liveJMSService.setContext(ctx1);

    liveJMSService.getHornetQServer().setIdentity("JMSLive");
    log.info("Starting life");

    liveJMSService.start();

    JMSUtil.waitForServer(backupService);
  }
Ejemplo n.º 20
0
  public void contextInitialized(Injector injector) {
    org.candlepin.common.config.Configuration candlepinConfig =
        injector.getInstance(org.candlepin.common.config.Configuration.class);

    if (hornetqServer == null) {
      Configuration config = new ConfigurationImpl();

      HashSet<TransportConfiguration> transports = new HashSet<TransportConfiguration>();
      transports.add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
      config.setAcceptorConfigurations(transports);

      // alter the default pass to silence log output
      config.setClusterUser(null);
      config.setClusterPassword(null);

      // in vm, who needs security?
      config.setSecurityEnabled(false);

      config.setJournalType(JournalType.NIO);

      config.setCreateBindingsDir(true);
      config.setCreateJournalDir(true);

      String baseDir = candlepinConfig.getString(ConfigProperties.HORNETQ_BASE_DIR);

      config.setBindingsDirectory(new File(baseDir, "bindings").toString());
      config.setJournalDirectory(new File(baseDir, "journal").toString());
      config.setLargeMessagesDirectory(new File(baseDir, "largemsgs").toString());
      config.setPagingDirectory(new File(baseDir, "paging").toString());

      Map<String, AddressSettings> settings = new HashMap<String, AddressSettings>();
      AddressSettings pagingConfig = new AddressSettings();

      String addressPolicyString =
          candlepinConfig.getString(ConfigProperties.HORNETQ_ADDRESS_FULL_POLICY);
      long maxQueueSizeInMb = candlepinConfig.getInt(ConfigProperties.HORNETQ_MAX_QUEUE_SIZE);
      long maxPageSizeInMb = candlepinConfig.getInt(ConfigProperties.HORNETQ_MAX_PAGE_SIZE);

      AddressFullMessagePolicy addressPolicy = null;
      if (addressPolicyString.equals("PAGE")) {
        addressPolicy = AddressFullMessagePolicy.PAGE;
      } else if (addressPolicyString.equals("BLOCK")) {
        addressPolicy = AddressFullMessagePolicy.BLOCK;
      } else {
        throw new IllegalArgumentException(
            "Unknown HORNETQ_ADDRESS_FULL_POLICY: "
                + addressPolicyString
                + " . Please use one of: PAGE, BLOCK");
      }

      // Paging sizes need to be converted to bytes
      pagingConfig.setMaxSizeBytes(maxQueueSizeInMb * FileUtils.ONE_MB);
      if (addressPolicy == AddressFullMessagePolicy.PAGE) {
        pagingConfig.setPageSizeBytes(maxPageSizeInMb * FileUtils.ONE_MB);
      }
      pagingConfig.setAddressFullMessagePolicy(addressPolicy);
      // Enable for all the queues
      settings.put("#", pagingConfig);
      config.setAddressesSettings(settings);

      int maxScheduledThreads =
          candlepinConfig.getInt(ConfigProperties.HORNETQ_MAX_SCHEDULED_THREADS);
      int maxThreads = candlepinConfig.getInt(ConfigProperties.HORNETQ_MAX_THREADS);
      if (maxThreads != -1) {
        config.setThreadPoolMaxSize(maxThreads);
      }

      if (maxScheduledThreads != -1) {
        config.setScheduledThreadPoolMaxSize(maxScheduledThreads);
      }

      /**
       * Anything up to size of LARGE_MSG_SIZE may be needed to be written to the Journal, so we
       * must set buffer size accordingly.
       *
       * <p>If buffer size would be < LARGE_MSG_SIZE we may get exceptions such as this: Can't write
       * records bigger than the bufferSize(XXXYYY) on the journal
       */
      int largeMsgSize = candlepinConfig.getInt(ConfigProperties.HORNETQ_LARGE_MSG_SIZE);
      config.setJournalBufferSize_AIO(largeMsgSize);
      config.setJournalBufferSize_NIO(largeMsgSize);

      hornetqServer = new EmbeddedHornetQ();
      hornetqServer.setConfiguration(config);
    }
    try {
      hornetqServer.start();
      log.info("Hornetq server started");
    } catch (Exception e) {
      log.error("Failed to start hornetq message server:", e);
      throw new RuntimeException(e);
    }

    setupAmqp(injector, candlepinConfig);
    cleanupOldQueues();

    List<String> listeners = getHornetqListeners(candlepinConfig);

    eventSource = injector.getInstance(EventSource.class);
    for (int i = 0; i < listeners.size(); i++) {
      try {
        Class<?> clazz = this.getClass().getClassLoader().loadClass(listeners.get(i));
        eventSource.registerListener((EventListener) injector.getInstance(clazz));
      } catch (Exception e) {
        log.warn("Unable to register listener " + listeners.get(i), e);
      }
    }

    // Initialize the Event sink AFTER the internal server has been
    // created and started.
    EventSink sink = injector.getInstance(EventSink.class);
    try {
      sink.initialize();
    } catch (Exception e) {
      log.error("Failed to initialize EventSink:", e);
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 21
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    Map<String, Object> acceptorParams = new HashMap<String, Object>();
    acceptorParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
    TransportConfiguration acceptorConfig =
        new TransportConfiguration(
            InVMAcceptorFactory.class.getName(), acceptorParams, RandomUtil.randomString());

    TransportConfiguration connectorConfig =
        new TransportConfiguration(
            InVMConnectorFactory.class.getName(), acceptorParams, RandomUtil.randomString());

    CoreQueueConfiguration sourceQueueConfig =
        new CoreQueueConfiguration(
            RandomUtil.randomString(), RandomUtil.randomString(), null, false);
    CoreQueueConfiguration targetQueueConfig =
        new CoreQueueConfiguration(
            RandomUtil.randomString(), RandomUtil.randomString(), null, false);
    List<String> connectors = new ArrayList<String>();
    connectors.add(connectorConfig.getName());
    bridgeConfig =
        new BridgeConfiguration(
            RandomUtil.randomString(),
            sourceQueueConfig.getName(),
            targetQueueConfig.getAddress(),
            null,
            null,
            HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
            HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
            HornetQClient.DEFAULT_CONNECTION_TTL,
            RandomUtil.randomPositiveLong(),
            HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
            RandomUtil.randomDouble(),
            RandomUtil.randomPositiveInt(),
            RandomUtil.randomBoolean(),
            RandomUtil.randomPositiveInt(),
            connectors,
            false,
            ConfigurationImpl.DEFAULT_CLUSTER_USER,
            ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD);

    Configuration conf_1 = createBasicConfig();
    conf_1.setSecurityEnabled(false);
    conf_1.setJMXManagementEnabled(true);
    conf_1.setClustered(true);
    conf_1.getAcceptorConfigurations().add(acceptorConfig);
    conf_1.getQueueConfigurations().add(targetQueueConfig);

    Configuration conf_0 = createBasicConfig();
    conf_0.setSecurityEnabled(false);
    conf_0.setJMXManagementEnabled(true);
    conf_0.setClustered(true);
    conf_0
        .getAcceptorConfigurations()
        .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    conf_0.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig);
    conf_0.getQueueConfigurations().add(sourceQueueConfig);
    conf_0.getBridgeConfigurations().add(bridgeConfig);

    server_1 =
        HornetQServers.newHornetQServer(conf_1, MBeanServerFactory.createMBeanServer(), false);
    addServer(server_1);
    server_1.start();

    server_0 = HornetQServers.newHornetQServer(conf_0, mbeanServer, false);
    addServer(server_0);
    server_0.start();
  }