Exemple #1
0
  /**
   * Pre tests the connection before starting the listening.
   *
   * <p>In case of connection failure the exception is thrown which prevents Camel from starting.
   *
   * @throws FailedToCreateConsumerException is thrown if testing the connection failed
   */
  protected void testConnectionOnStartup() throws FailedToCreateConsumerException {
    try {
      log.debug("Testing JMS Connection on startup for destination: {}", getDestinationName());
      Connection con = listenerContainer.getConnectionFactory().createConnection();
      JmsUtils.closeConnection(con);

      log.info(
          "Successfully tested JMS Connection on startup for destination: " + getDestinationName());
    } catch (Exception e) {
      String msg = "Cannot get JMS Connection on startup for destination " + getDestinationName();
      throw new FailedToCreateConsumerException(getEndpoint(), msg, e);
    }
  }