Powered By Blogger

May 23, 2017

Understanding WSO2 ESB Mediation Flow

This blog post describes about the message flow of the synapse mediation engine and I hope this post will help to get a basic idea about the mediation flow. 

First the message comes to the transport layer and it takes care of the transport protocol transformations required by the ESB. The receiving transport selects a relevant message builder based on the message's content type and also before a transport sends a message out from the ESB, a message formatter is used to build the outgoing message.Then it passes to the synapse mediation engine and below flow shows the methods which will get executed in the request and response paths. 


Following methods will get executed in the Request flow

  • org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(MessageContext mc)
  • org.apache.synapse.mediators.base.SequenceMediator.mediate(MessageContext synCtx)
  • org.apache.synapse.mediators.AbstractListMediator.mediate(MessageContext synCtx, int)
  • org.apache.synapse.mediators.builtin.SendMediator.mediate(MessageContext synCtx)
  • org.apache.synapse.endpoints.AbstractEndpoint.send(MessageContext synCtx)
  • org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(EndpointDefinition endpoint, MessageContext synCtx)
  • org.apache.synapse.core.axis2.Axis2Sender.sendOn(EndpointDefinition endpoint, MessageContext synapseInMessageContext)
  • org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(EndpointDefinition endpoint, org.apache.synapse.MessageContext synapseOutMessageContext)
  • org.apache.axis2.engine.AxisEngine.send(MessageContext msgContext)

Below methods will get executed in the Response flow

  • org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(MessageContext messageCtx) 
  • org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(String messageID, MessageContext response, MessageContext synapseOutMsgCtx, AsyncCallback callback)
  • org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(MessageContext synCtx)
  • org.apache.synapse.mediators.base.SequenceMediator.mediate(MessageContext synCtx)
  • org.apache.synapse.mediators.AbstractListMediator.mediate(MessageContext synCtx, int)
  • org.apache.synapse.mediators.builtin.SendMediator.mediate(MessageContext synCtx)
  • org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(EndpointDefinition endpoint, MessageContext synCtx)
  • org.apache.synapse.core.axis2.Axis2Sender.sendBack(MessageContext smc)
  • org.apache.axis2.engine.AxisEngine.send(MessageContext msgContext)



Please find the proxy configuration below




<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SampleProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <send>
            <endpoint>
               <address uri="http://www.mocky.io/v2/591b089c120000c3037788ae"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>