<!-- Introduction to Synapse Content Based Router eip function template -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<import xmlns="http://ws.apache.org/ns/synapse" name="EipLibrary" package="synapse.lang.eip" />
<proxy name="StockQuoteProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<call-template target="synapse.lang.eip.content_based_router">
<with-param name="routing_exp" value="{{//m0:getQuote/m0:request/m0:symbol}}" xmlns:m0="http://services.samples"/>
<with-param name="match_content" value="IBM:cnd1_seq,MSFT:cnd2_seq;cnd3_seq"/>
</call-template>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
<sequence name="send_seq">
<log level="custom">
<property name="DEBUG" value="Condition Satisfied"/>
</log>
<send>
<endpoint name="simple">
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</sequence>
<sequence name="cnd1_seq">
<log level="custom">
<property name="MSG_FLOW" value="Condition (I) Satisfied"/>
</log>
<sequence key="send_seq"/>
</sequence>
<sequence name="cnd2_seq">
<log level="custom">
<property name="MSG_FLOW" value="Condition (II) Satisfied"/>
</log>
<sequence key="send_seq"/>
</sequence>
<sequence name="cnd3_seq">
<log level="custom">
<property name="MSG_FLOW" value="Condition (III) Satisfied"/>
</log>
<sequence key="send_seq"/>
</sequence>
</definitions>
Executing the Client
In this sample, it routes the message by matching the specified Xpath to the regular expression. Execute the StockQuote client in the dumb client mode, specifying 'IBM', 'MSFT' and 'DELL' as the stock symbols.
When the symbol IBM is requested, you will see cnd1_seq sequence is getting executed.
ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=IBM
When the symbol MSFT is requested, you will see cnd2_seq sequence is getting executed.
ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=MSFT
When the symbol DELL is requested, you will see cnd3_seq sequence is getting executed , which is the default sequence.
ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=DELL