}
public MessageProcessor createOutboundMessageProcessorChain(OutboundEndpoint endpoint, FlowConstruct flowConstruct, MessageProcessor target) throws MuleException
{
// -- REQUEST CHAIN --
DefaultMessageProcessorChainBuilder outboundChainBuilder = new EndpointMessageProcessorChainBuilder(endpoint, flowConstruct);
outboundChainBuilder.setName("OutboundEndpoint '" + endpoint.getEndpointURI().getUri() + "' request chain");
// Default MPs
outboundChainBuilder.chain(createOutboundMessageProcessors(endpoint));
// Configured MPs (if any)
outboundChainBuilder.chain(endpoint.getMessageProcessors());
// -- OUTBOUND ROUTER --
if (target == null)
{
throw new ConfigurationException(MessageFactory.createStaticMessage("No listener (target) has been set for this endpoint"));
}
outboundChainBuilder.chain(target);
// -- RESPONSE CHAIN --
DefaultMessageProcessorChainBuilder responseChainBuilder = new EndpointMessageProcessorChainBuilder(endpoint, flowConstruct);
responseChainBuilder.setName("OutboundEndpoint '" + endpoint.getEndpointURI().getUri() + "' response chain");
// Default MPs
responseChainBuilder.chain(createOutboundResponseMessageProcessors(endpoint));
// Configured MPs (if any)
responseChainBuilder.chain(endpoint.getResponseMessageProcessors());
// Compose request and response chains. We do this so that if the request
// chain returns early the response chain is still invoked.
DefaultMessageProcessorChainBuilder compositeChainBuilder = new EndpointMessageProcessorChainBuilder(endpoint, flowConstruct);
compositeChainBuilder.setName("OutboundEndpoint '" + endpoint.getEndpointURI().getUri() + "' composite request/response chain");
compositeChainBuilder.chain(outboundChainBuilder.build(), responseChainBuilder.build());
return compositeChainBuilder.build();
}