@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 (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());
}
executorService = ExecutorServiceHelper.getConfiguredExecutorService(routeContext, "RecipientList", this);
if (isParallelProcessing() && executorService == null) {
// we are running in parallel so create a thread pool
executorService = routeContext.getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this, "RecipientList");
}
answer.setExecutorService(executorService);
long timeout = getTimeout() != null ? getTimeout() : 0;
if (timeout > 0 && !isParallelProcessing()) {
throw new IllegalArgumentException("Timeout is used but ParallelProcessing has not been enabled.");
}