Пример #1
0
  @Override
  @After
  public void tearDown() throws Exception {
    backupJMSService.stop();

    liveJMSService.stop();

    Assert.assertEquals(0, InVMRegistry.instance.size());

    liveService = null;

    liveJMSService = null;

    backupJMSService = null;

    ctx1 = null;

    ctx2 = null;

    backupService = null;

    backupParams = null;

    super.tearDown();
  }
Пример #2
0
  @Test
  public void testCreateTopic() throws Exception {
    liveJMSService.createTopic(true, "topic", "/topic/t1");
    assertNotNull(ctx1.lookup("//topic/t1"));

    ActiveMQConnectionFactory jbcf =
        ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, livetc);

    jbcf.setReconnectAttempts(-1);

    Connection conn = null;

    try {
      conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5);

      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      ClientSession coreSession = ((ActiveMQSession) sess).getCoreSession();

      JMSUtil.crash(liveService, coreSession);

      assertNotNull(ctx2.lookup("/topic/t1"));
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
  }
Пример #3
0
  /** @throws Exception */
  protected void startServers() throws Exception {
    final boolean sharedStore = true;
    NodeManager nodeManager = new InVMNodeManager(!sharedStore);
    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);

    backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);

    backupConf =
        createBasicConfig(0)
            .addAcceptorConfiguration(backupAcceptortc)
            .addConnectorConfiguration(livetc.getName(), livetc)
            .addConnectorConfiguration(backuptc.getName(), backuptc)
            .setSecurityEnabled(false)
            .setJournalType(getDefaultJournalType())
            .addAcceptorConfiguration(
                new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams))
            .setBindingsDirectory(getBindingsDir())
            .setJournalMinFiles(2)
            .setJournalDirectory(getJournalDir())
            .setPagingDirectory(getPageDir())
            .setLargeMessagesDirectory(getLargeMessagesDir())
            .setPersistenceEnabled(true)
            .setHAPolicyConfiguration(
                sharedStore
                    ? new SharedStoreSlavePolicyConfiguration()
                    : new ReplicaPolicyConfiguration())
            .addClusterConfiguration(
                basicClusterConnectionConfig(backuptc.getName(), livetc.getName()));

    backupService = new InVMNodeManagerServer(backupConf, nodeManager);

    backupJMSService = new JMSServerManagerImpl(backupService);

    backupJMSService.setRegistry(new JndiBindingRegistry(ctx2));

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

    liveConf =
        createBasicConfig(0)
            .setJournalDirectory(getJournalDir())
            .setBindingsDirectory(getBindingsDir())
            .setSecurityEnabled(false)
            .addAcceptorConfiguration(liveAcceptortc)
            .setJournalType(getDefaultJournalType())
            .setBindingsDirectory(getBindingsDir())
            .setJournalMinFiles(2)
            .setJournalDirectory(getJournalDir())
            .setPagingDirectory(getPageDir())
            .setLargeMessagesDirectory(getLargeMessagesDir())
            .addConnectorConfiguration(livetc.getName(), livetc)
            .setPersistenceEnabled(true)
            .setHAPolicyConfiguration(
                sharedStore
                    ? new SharedStoreMasterPolicyConfiguration()
                    : new ReplicatedPolicyConfiguration())
            .addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));

    liveService = new InVMNodeManagerServer(liveConf, nodeManager);

    liveJMSService = new JMSServerManagerImpl(liveService);

    liveJMSService.setRegistry(new JndiBindingRegistry(ctx1));

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

    liveJMSService.start();

    JMSUtil.waitForServer(backupService);
  }