<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<document>
    <properties>
        <title>Apache Synapse - Sample 62</title>
    </properties>
    <body>
        <section name="Sample 62: Routing message to dynamic recipients">
            <div class="xmlConf">&lt;definitions xmlns=&quot;http://ws.apache.org/ns/synapse&quot;&gt;
   &lt;sequence name=&quot;errorHandler&quot;&gt;
      &lt;makefault response=&quot;true&quot;&gt;
         &lt;code xmlns:tns=&quot;http://www.w3.org/2003/05/soap-envelope&quot; value=&quot;tns:Receiver&quot; /&gt;
         &lt;reason value=&quot;COULDN&#39;T SEND THE MESSAGE TO THE SERVER.&quot; /&gt;
      &lt;/makefault&gt;
      &lt;send /&gt;
   &lt;/sequence&gt;
   &lt;sequence name=&quot;fault&quot;&gt;
      &lt;log level=&quot;full&quot;&gt;
         &lt;property name=&quot;MESSAGE&quot; value=&quot;Executing default &amp;quot;fault&amp;quot; sequence&quot; /&gt;
         &lt;property name=&quot;ERROR_CODE&quot; expression=&quot;get-property(&#39;ERROR_CODE&#39;)&quot; /&gt;
         &lt;property name=&quot;ERROR_MESSAGE&quot; expression=&quot;get-property(&#39;ERROR_MESSAGE&#39;)&quot; /&gt;
      &lt;/log&gt;
      &lt;drop /&gt;
   &lt;/sequence&gt;
   &lt;sequence name=&quot;main&quot; onError=&quot;errorHandler&quot;&gt;
      &lt;in&gt;
         &lt;property name=&quot;EP_LIST&quot; value=&quot;http://localhost:9001/services/SimpleStockQuoteService,http://localhost:9002/services/SimpleStockQuoteService,http://localhost:9003/services/SimpleStockQuoteService&quot;/&gt;	
         &lt;send&gt;
            &lt;endpoint&gt;
               &lt;recipientlist&gt;
                  &lt;endpoints value=&quot;{get-property(&#39;EP_LIST&#39;)}&quot; max-cache=&quot;20&quot; /&gt;
               &lt;/recipientlist&gt;
            &lt;/endpoint&gt;
         &lt;/send&gt;
         &lt;drop/&gt;
      &lt;/in&gt;
      &lt;out&gt;
        &lt;!--Aggregate responses--&gt;
        &lt;aggregate&gt;
           &lt;onComplete xmlns:m0=&quot;http://services.samples&quot;
                          expression=&quot;//m0:getQuoteResponse&quot;&gt;
             &lt;log level=&quot;full&quot;/&gt;
             &lt;send/&gt;
           &lt;/onComplete&gt;
        &lt;/aggregate&gt;
      &lt;/out&gt;
   &lt;/sequence&gt;
&lt;/definitions&gt;</div>
            <subsection name="Objective">
                <p>
                    Objective: Routing message to dynamic recipients
                </p>
            </subsection>
            <subsection name="Pre-requisites">
                <p>
                    <ul>
                        <li>Start ESB with sample configuration 62. (i.e. wso2esb-samples -sn 62) </li>

                        <li>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 </li>

                    </ul>
                </p>
            </subsection>
            <subsection name="Executing the Client">
                <p>
                    Invoke the sample client as follows
                </p>
                <div class="command">ant stockquote -Dtrpurl=http://localhost:8280/</div>
                
            </subsection>
        </section>
        <p>
            <a href="../samples.html">Back to Catalog</a>
        </p>
    </body>
</document>
