message.addProperties(messageProperties, PropertyScope.INBOUND);
message.addProperties(messageProperties, PropertyScope.INVOCATION);
// Use an endpoint cache to prevent memory leaks (see MULE-5422)
OutboundEndpoint ep = endpointCache.getOutboundEndpoint(endpoint, exchangePattern, null);
DefaultMuleEvent event = new DefaultMuleEvent(message, ep.getExchangePattern(),
new DefaultMuleSession(flowConstruct, muleContext));
RequestContext.setEvent(event);
// Set correlation properties in SESSION scope so that they get propagated to response messages.
if (messageProperties.get(PROPERTY_PROCESS_TYPE) != null)
{
event.getMessage().setSessionProperty(PROPERTY_PROCESS_TYPE, messageProperties.get(PROPERTY_PROCESS_TYPE));
}
if (messageProperties.get(PROPERTY_PROCESS_ID) != null)
{
event.getMessage().setSessionProperty(PROPERTY_PROCESS_ID, messageProperties.get(PROPERTY_PROCESS_ID));
}
MuleEvent resultEvent = ep.process(event);
MuleMessage response = null;