Tuesday, August 2, 2016

Creating a Delay in message processing at synapse level in WSO2 ESB

To reproduce some network delay scenarios, we may need to delay the message processing, to achieve this in ESB synapse level we can use script mediator like below: ( Here 1000 is in ms ).



Find the sample proxy service as below:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="PassThrougghProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <script language="js">java.lang.Thread.sleep(1000);</script>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="http://www.webservicex.com/globalweather.asmx?wsdl"/>
      </endpoint>
   </target>
   <description/>
</proxy>