예제 #1
0
  /** Cleans up all resources that are still in use. */
  public synchronized void close() {
    for (ClientConsumer consumer : dataConsumers) {
      try {
        consumer.close();
      } catch (HornetQException e) {
        // ignore exception
      }
    }

    dataConsumers.clear();

    try {
      if (session != null) {
        session.close();
      }
    } catch (Exception e) {
      // ignore exception
    } finally {
      if (sessionFactory != null) {
        sessionFactory.close();
      }
      if (locator != null) {
        locator.close();
      }
    }

    for (ConnectionListener cl : connectionListeners) {
      cl.disconnected();
    }
  }
예제 #2
0
  public void beforeReconnect(HornetQException e) {
    logger.warn("disconnected from yamcs: {}", e.getMessage());
    for (ConnectionListener cl : connectionListeners) {
      cl.disconnected();
      cl.log(e.getMessage());
    }

    // clear all pending messages in the data consumers, as they will be re-submitted
    // by yamcs upon re-connect
    for (ClientConsumer consumer : dataConsumers) {
      try {
        MessageHandler handler = consumer.getMessageHandler();
        if (handler instanceof ClientAckMessageHandler) {
          ((ClientAckMessageHandler) handler).clearPendingMessages();
        }
      } catch (HornetQException e1) {
        // ignore
      }
    }
  }