use of org.apache.camel.processor.resequencer.ExpressionResultComparator in project camel by apache.
the class ResequenceDefinition method createStreamResequencer.
/**
* Creates a {@link StreamResequencer} instance applying the given <code>config</code>.
*
* @param routeContext route context.
* @param config stream resequencer configuration.
* @return the configured stream resequencer.
* @throws Exception can be thrwon
*/
protected StreamResequencer createStreamResequencer(RouteContext routeContext, StreamResequencerConfig config) throws Exception {
Processor processor = this.createChildProcessor(routeContext, true);
Expression expression = getExpression().createExpression(routeContext);
CamelInternalProcessor internal = new CamelInternalProcessor(processor);
internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(routeContext));
ObjectHelper.notNull(config, "config", this);
ObjectHelper.notNull(expression, "expression", this);
ExpressionResultComparator comparator;
if (config.getComparatorRef() != null) {
comparator = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), config.getComparatorRef(), ExpressionResultComparator.class);
} else {
comparator = config.getComparator();
}
comparator.setExpression(expression);
StreamResequencer resequencer = new StreamResequencer(routeContext.getCamelContext(), internal, comparator, expression);
resequencer.setTimeout(config.getTimeout());
resequencer.setCapacity(config.getCapacity());
resequencer.setRejectOld(config.getRejectOld());
if (config.getIgnoreInvalidExchanges() != null) {
resequencer.setIgnoreInvalidExchanges(config.getIgnoreInvalidExchanges());
}
return resequencer;
}
Aggregations