Child pages
  • Sample 600 : Simple Message Transformation - Rule Mediator for Message Transformation

This documentation is for WSO2 ESB version 4.5.1. View documentation for the latest release.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Objective: Introduction to simple rule based routing.

<!-- Simple rule based routing  of messages - same as filter mediator -->
<definitions xmlns="">
            <ruleset >
                    <package name="SimpleRoutingRules"
                             xs:schemaLocation=" drools-4.0.xsd">
                        <import name="org.apache.synapse.MessageContext"/>
                        <rule name="Invoke IBM ">
                                <pattern object-type="MessageContext" identifier="mc"></pattern>
                                <pattern object-type="String" identifier="symbol"></pattern>
                    <property name="source" value="xml"/>
            <session type="stateless"/>
                <fact name="mc" type="context"/>
                <fact name="symbol" type="java.lang.String"
                        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>



  • Start the Synapse configuration numbered 600: (i.e. ./ -sn 600)
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed.

Run the client as

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/

Or as

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM

Then, you will get stock quote price in the client side.

In this sample , with in the rule mediator , the value, which is extracted from the SOAP envelope using XPath '//m0:getQuote/m0:request/m0:symbol', is added to the rule engine as a string fact . The message context property named "execute_children" is to indicate it is need to execute the child mediators of rule mediator. That property is set only if the symbol is IBM.

Now use following commands

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN


ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT

Then , you will get errors . This is because , 'symbol' is not equal to "IBM".

  • No labels