logger.debug("sending reply to: " + replyTo);
}
String replyToEndpoint = replyTo.toString();
// get the endpoint for this url
OutboundEndpoint endpoint = getEndpoint(event, replyToEndpoint);
// make sure remove the replyTo property as not cause a a forever
// replyto loop
returnMessage.removeProperty(MuleProperties.MULE_REPLY_TO_PROPERTY);
// MULE-4617. This is fixed with MULE-4620, but lets remove this property
// anyway as it should never be true from a replyTo dispatch
returnMessage.removeProperty(MuleProperties.MULE_REMOTE_SYNC_PROPERTY);
// Create a new copy of the message so that response MessageProcessors don't end up screwing up the reply
returnMessage = new DefaultMuleMessage(returnMessage.getPayload(), returnMessage, muleContext);
// Create the replyTo event asynchronous
MuleEvent replyToEvent = new DefaultMuleEvent(returnMessage, event.getEndpoint(), event.getSession(), event.getProcessingTime());
// carry over properties
List<String> responseProperties = endpoint.getResponseProperties();
for (String propertyName : responseProperties)
{
Object propertyValue = event.getMessage().getInboundProperty(propertyName);
if (propertyValue != null)
{
replyToEvent.getMessage().setOutboundProperty(propertyName, propertyValue);
}
}
// dispatch the event
try
{
if (event.getFlowConstruct() instanceof Service)
{
ServiceStatistics stats = ((Service) event.getFlowConstruct()).getStatistics();
if (stats.isEnabled())
{
stats.incSentReplyToEvent();
}
}
endpoint.process(replyToEvent);
if (logger.isInfoEnabled())
{
logger.info("reply to sent: " + endpoint);
}
}