## Apache Synapse

## Sample 62: Routing message to dynamic recipients

<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="errorHandler"> <makefault response="true"> <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver" /> <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER." /> </makefault> <send /> </sequence> <sequence name="fault"> <log level="full"> <property name="MESSAGE" value="Executing default &quot;fault&quot; sequence" /> <property name="ERROR_CODE" expression="get-property('ERROR_CODE')" /> <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')" /> </log> <drop /> </sequence> <sequence name="main" onError="errorHandler"> <in> <property name="EP_LIST" value="http://localhost:9001/services/SimpleStockQuoteService,http://localhost:9002/services/SimpleStockQuoteService,http://localhost:9003/services/SimpleStockQuoteService"/> <send> <endpoint> <recipientlist> <endpoints value="{get-property('EP_LIST')}" max-cache="20" /> </recipientlist> </endpoint> </send> <drop/> </in> <out> <!--Aggregate responses--> <aggregate> <onComplete xmlns:m0="http://services.samples" expression="//m0:getQuoteResponse"> <log level="full"/> <send/> </onComplete> </aggregate> </out> </sequence> </definitions>

### Objective

Objective: Routing message to dynamic recipients

### Pre-requisites

- Start ESB with sample configuration 62. (i.e. wso2esb-samples -sn 62)
- Start three instances of the sample Axis2 server on HTTP ports 9001, 9002 and 9003 and give unique names to each server. For instructions on starting the Axis2 server, see Starting the Axis2 server

### Executing the Client

Invoke the sample client as follows

ant stockquote -Dtrpurl=http://localhost:8280/

Back to Catalog