DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
builder.setName("'async' child chain");
final MuleConfiguration config = muleContext.getConfiguration();
final String threadPrefix = ThreadNameHelper.asyncProcessor(muleContext, name);
AsyncDelegateMessageProcessor asyncProcessor = new AsyncDelegateMessageProcessor(threadingProfile,
threadPrefix,
config.getShutdownTimeout());
for (Object processor : messageProcessors)
{
if (processor instanceof MessageProcessor)
{
builder.chain((MessageProcessor) processor);
}
else if (processor instanceof MessageProcessorBuilder)
{
builder.chain((MessageProcessorBuilder) processor);
}
else
{
throw new IllegalArgumentException(
"MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
}
}
asyncProcessor.setDelegate(builder.build());
return asyncProcessor;
}