}
public MessageProcessor createInboundMessageProcessorChain(InboundEndpoint endpoint, FlowConstruct flowConstruct, MessageProcessor target) throws MuleException
{
// -- REQUEST CHAIN --
DefaultMessageProcessorChainBuilder requestChainBuilder = new EndpointMessageProcessorChainBuilder(endpoint, flowConstruct);
requestChainBuilder.setName("InboundEndpoint '" + endpoint.getEndpointURI().getUri() + "' request chain");
// Default MPs
requestChainBuilder.chain(createInboundMessageProcessors(endpoint));
// Configured MPs (if any)
AbstractRedeliveryPolicy redeliveryPolicy = endpoint.getRedeliveryPolicy();
if (redeliveryPolicy != null)
{
requestChainBuilder.chain(redeliveryPolicy);
}
requestChainBuilder.chain(endpoint.getMessageProcessors());
// -- INVOKE FLOW --
if (target == null)
{
throw new ConfigurationException(MessageFactory.createStaticMessage("No listener (target) has been set for this endpoint"));
}
requestChainBuilder.chain(target);
if (!endpoint.getExchangePattern().hasResponse())
{
return requestChainBuilder.build();
}
else
{
// -- RESPONSE CHAIN --
DefaultMessageProcessorChainBuilder responseChainBuilder = new EndpointMessageProcessorChainBuilder(endpoint, flowConstruct);
responseChainBuilder.setName("InboundEndpoint '" + endpoint.getEndpointURI().getUri() + "' response chain");
// Default MPs
responseChainBuilder.chain(createInboundResponseMessageProcessors(endpoint));
// Configured MPs (if any)
responseChainBuilder.chain(endpoint.getResponseMessageProcessors());
// -- COMPOSITE REQUEST/RESPONSE CHAIN --
// 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("InboundEndpoint '"+ endpoint.getEndpointURI().getUri() +"' composite request/response chain");
compositeChainBuilder.chain(requestChainBuilder.build(), responseChainBuilder.build());
return compositeChainBuilder.build();
}
}