Search in sources :

Example 1 with ExpressionResultComparator

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;
}
Also used : CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) Processor(org.apache.camel.Processor) Expression(org.apache.camel.Expression) ExpressionResultComparator(org.apache.camel.processor.resequencer.ExpressionResultComparator) StreamResequencer(org.apache.camel.processor.StreamResequencer)

Aggregations

Expression (org.apache.camel.Expression)1 Processor (org.apache.camel.Processor)1 CamelInternalProcessor (org.apache.camel.processor.CamelInternalProcessor)1 StreamResequencer (org.apache.camel.processor.StreamResequencer)1 ExpressionResultComparator (org.apache.camel.processor.resequencer.ExpressionResultComparator)1