* @throws org.mule.api.MuleException if there is no outbound endpoint configured
* on the service or the events fails during dispatch
*/
public void dispatchEvent(MuleMessage message) throws MuleException
{
FlowConstruct flowConstruct = session.getFlowConstruct();
if (flowConstruct == null)
{
throw new IllegalStateException(CoreMessages.objectIsNull("flowConstruct").getMessage());
}
else if (!(flowConstruct instanceof Service))
{
throw new UnsupportedOperationException(
"EventContext.dispatchEvent is only supported when flow constuct is a Service");
}
else
{
MessageProcessor processor = ((Service) flowConstruct).getOutboundMessageProcessor();
if (processor == null)
{
throw new EndpointNotFoundException(
CoreMessages.noOutboundRouterSetOn(flowConstruct.getName()));
}
processor.process(new DefaultMuleEvent(message, RequestContext.getEvent()));
}
}