コード例 #1
0
  @Override
  public Processor createProcessor(RouteContext routeContext) throws Exception {
    if (ObjectHelper.isEmpty(resourceUri) && ObjectHelper.isEmpty(resourceRef)) {
      throw new IllegalArgumentException(
          "Either uri or ref must be provided for resource endpoint");
    }

    // lookup endpoint
    Endpoint endpoint;
    if (resourceUri != null) {
      endpoint = routeContext.resolveEndpoint(resourceUri);
    } else {
      endpoint = routeContext.resolveEndpoint(null, resourceRef);
    }

    PollEnricher enricher;
    if (timeout != null) {
      enricher = new PollEnricher(null, endpoint.createPollingConsumer(), timeout);
    } else {
      // if no timeout then we should block, and there use a negative timeout
      enricher = new PollEnricher(null, endpoint.createPollingConsumer(), -1);
    }

    AggregationStrategy strategy = createAggregationStrategy(routeContext);
    if (strategy == null) {
      enricher.setDefaultAggregationStrategy();
    } else {
      enricher.setAggregationStrategy(strategy);
    }
    if (getAggregateOnException() != null) {
      enricher.setAggregateOnException(getAggregateOnException());
    }

    return enricher;
  }