@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
final Expression expression = getExpression().createExpression(routeContext);
RecipientList answer;
if (delimiter != null) {
answer = new RecipientList(routeContext.getCamelContext(), expression, delimiter);
} else {
answer = new RecipientList(routeContext.getCamelContext(), expression);
}
answer.setAggregationStrategy(createAggregationStrategy(routeContext));
answer.setParallelProcessing(isParallelProcessing());
answer.setStreaming(isStreaming());
answer.setShareUnitOfWork(isShareUnitOfWork());
if (getCacheSize() != null) {
answer.setCacheSize(getCacheSize());
}
if (onPrepareRef != null) {
onPrepare = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), onPrepareRef, Processor.class);
}
if (onPrepare != null) {
answer.setOnPrepare(onPrepare);
}
if (stopOnException != null) {
answer.setStopOnException(isStopOnException());
}
if (ignoreInvalidEndpoints != null) {
answer.setIgnoreInvalidEndpoints(ignoreInvalidEndpoints);
}
if (getTimeout() != null) {
answer.setTimeout(getTimeout());
}
boolean shutdownThreadPool = ProcessorDefinitionHelper.willCreateNewThreadPool(routeContext, this, isParallelProcessing());
ExecutorService threadPool = ProcessorDefinitionHelper.getConfiguredExecutorService(routeContext, "RecipientList", this, isParallelProcessing());
answer.setExecutorService(threadPool);
answer.setShutdownExecutorService(shutdownThreadPool);
long timeout = getTimeout() != null ? getTimeout() : 0;
if (timeout > 0 && !isParallelProcessing()) {
throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
}