예제 #1
0
  @Override
  public boolean process(Exchange exchange, OptionalAsyncResultHandler optionalAsyncResultHandler)
      throws Exception {
    boolean isMatched = false;
    try {
      isMatched = getPredicate().matches(exchange);
    } catch (Exception e) {
      exchange.setException(e);
      optionalAsyncResultHandler.done(exchange);
    }

    logger.debug("Filter matches: {} for exchange: {}", isMatched, exchange.toString());

    if (isMatched) {
      return super.process(exchange, optionalAsyncResultHandler);
    } else {
      optionalAsyncResultHandler.done(exchange);
      return true;
    }
  }
예제 #2
0
  public boolean process(Exchange exchange, OptionalAsyncResultHandler optionalAsyncResultHandler)
      throws Exception {
    if (endpoint.getConsumer() == null) {
      LOG.warn("No consumers available on endpoint: " + endpoint + " to process: " + exchange);
      // indicate its done synchronously
      exchange.setException(
          new DirectConsumerNotAvailableException(
              "No consumers available on endpoint: " + endpoint, exchange));
      optionalAsyncResultHandler.done(exchange);
      return true;
    } else {
      AsyncProcessor processor =
          AsyncProcessorConverterHelper.convert(endpoint.getConsumer().getProcessor());

      return processor.process(exchange, optionalAsyncResultHandler);
    }
  }