Ejemplo n.º 1
1
  /** Teardown the activation */
  protected synchronized void teardown() {
    HornetQRALogger.LOGGER.debug("Tearing down " + spec);

    if (resourceRecovery != null) {
      ra.getRecoveryManager().unRegister(resourceRecovery);
    }

    for (HornetQMessageHandler handler : handlers) {
      handler.interruptConsumer();
    }

    Thread threadTearDown =
        new Thread("TearDown/HornetQActivation") {
          public void run() {
            for (HornetQMessageHandler handler : handlers) {
              handler.teardown();
            }
          }
        };

    // We will first start a new thread that will call tearDown on all the instances, trying to
    // graciously shutdown everything.
    // We will then use the call-timeout to determine a timeout.
    // if that failed we will then close the connection factory, and interrupt the thread
    threadTearDown.start();

    try {
      threadTearDown.join(factory.getCallTimeout());
    } catch (InterruptedException e) {
      // nothing to be done on this context.. we will just keep going as we need to send an
      // interrupt to threadTearDown and give up
    }

    if (threadTearDown.isAlive()) {
      if (factory != null) {
        // This will interrupt any threads waiting on reconnect
        factory.close();
        factory = null;
      }
      threadTearDown.interrupt();

      try {
        threadTearDown.join(5000);
      } catch (InterruptedException e) {
        // nothing to be done here.. we are going down anyways
      }

      if (threadTearDown.isAlive()) {
        HornetQRALogger.LOGGER.warn("Thread " + threadTearDown + " couldn't be finished");
      }
    }

    if (spec.isHasBeenUpdated() && factory != null) {
      factory.close();
      factory = null;
    }

    HornetQRALogger.LOGGER.debug("Tearing down complete " + this);
  }
Ejemplo n.º 2
0
  @Override
  protected void tearDown() throws Exception {

    cf1.close();

    cf2.close();

    if (jmsServer != null && jmsServer.isStarted()) {
      jmsServer.stop();
    }

    super.tearDown();
  }
Ejemplo n.º 3
0
  @Override
  @After
  public void tearDown() throws Exception {
    checkEmpty(sourceQueue, 0);
    checkEmpty(localTargetQueue, 0);
    checkEmpty(targetQueue, 1);

    // Check no subscriptions left lying around

    checkNoSubscriptions(sourceTopic, 0);
    if (cff0 instanceof HornetQConnectionFactory) {
      ((HornetQConnectionFactory) cff0).close();
    }
    if (cff1 instanceof HornetQConnectionFactory) {
      ((HornetQConnectionFactory) cff1).close();
    }
    stopComponent(jmsServer0);
    stopComponent(jmsServer1);
    cff0 = cff1 = null;
    cff0xa = cff1xa = null;

    cf0 = cf1 = null;

    cf0xa = cf1xa = null;

    sourceQueueFactory = targetQueueFactory = localTargetQueueFactory = sourceTopicFactory = null;

    sourceQueue = targetQueue = localTargetQueue = null;

    sourceTopic = null;

    server0 = null;

    jmsServer0 = null;

    server1 = null;

    jmsServer1 = null;
    if (context0 != null) context0.close();
    context0 = null;
    if (context1 != null) context1.close();
    context1 = null;

    // Shutting down Arjuna threads
    TxControl.disable(true);

    TransactionReaper.terminate(false);
    super.tearDown();
  }
Ejemplo n.º 4
0
  @Override
  protected void tearDown() throws Exception {

    try {
      jmsServer2.stop();

      server2.stop();

      context2.close();
    } catch (Throwable e) {
      log.warn("Can't stop server2", e);
    }

    ((HornetQConnectionFactory) cf1).close();

    ((HornetQConnectionFactory) cf2).close();

    server2 = null;

    jmsServer2 = null;

    context2 = null;

    cf1 = null;

    try {
      jmsServer1.stop();

      server1.stop();

      context1.close();
    } catch (Throwable e) {
      log.warn("Can't stop server2", e);
    }

    server1 = null;

    jmsServer1 = null;

    context1 = null;

    super.tearDown();
  }
Ejemplo n.º 5
0
  @After
  public void tearDown() {
    try {
      if (session != null) {
        session.close();
      }

      if (connection != null) {
        connection.close();
      }

      if (hornetQConnectionFactory != null) {
        hornetQConnectionFactory.close();
      }

    } catch (JMSException e) {
      e.printStackTrace();
    }
  }