This documentation is for WSO2 Enterprise Service Bus version 4.9.0 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Assume that you have a configuration that sends the request to the Stock Quote service and changes the response value when the symbol is WSO2 or CRF. Also assume that you want to temporarily change the configuration so that if the symbol is CRF, the ESB just sends the message back to the client without sending it to the Stock Quote service or performing any additional processing. To achieve this, you can add the Respond mediator at the beginning of the CRF case as shown below. All the configuration after the Respond mediator is ignored. As a result, the rest of the CRF case configuration is left intact, allowing you to easily revert to the original behavior in the future simply by removing the Respond mediator if required.

Code Block
XML
XML
<definitions xmlns="http://ws.apache.org/ns/synapse">
  <sequence name="main">
    <in>
      <switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples">
        <case regex="WSO2">
          <property name="symbol" value="Great stock - WSO2"/>
          <send>
            <endpoint>
              <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
          </send>
        </case>
        <case regex="CRF">

          <respond/>

          <property name="symbol" value="Are you sure? - CRF"/>
            <send>
              <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
              </endpoint>
            </send>
        </case>
        <default>
          <property name="symbol"
            expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)" 
xmlns:m0="http://services.samples"/>
        </default>
      </switch>
    </in>
    <out>
      <send/>
    </out>
  </sequence>
</definitions>