This documentation is for WSO2 Enterprise Service Bus version 4.7.0 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

Objective: Demonstrate message routing to a set of dynamic endpoints and aggregate responses.

Prerequisites

Start ESB with the following sample configuration:

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
    <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
        <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
        <parameter name="root">file:repository/conf/sample/resources/</parameter>
        <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
        <parameter name="cachableDuration">15000</parameter>
    </registry>
    <sequence name="main" onError="errorHandler">
        <in>
        <!--Dynamic Recipient List-->
            <send>
                <endpoint>
                   <recipientlist>
                        <endpoints value="{get-property('registry','recipients/EP_LIST')}"/>
                    </recipientlist>
                </endpoint>
            </send>
            <drop/>
        </in>
        <out>
        <log level="full"/>
        <!--Aggregate responses-->
            <aggregate>
              <onComplete xmlns:m0="http://services.samples"
                          expression="//m0:getQuoteResponse">
                 <send/>
          </onComplete>
        </aggregate>
        </out>
    </sequence>
    <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>
</definitions>

Deploy the SimpleStockQuoteService and start three instances of sample Axis2 server as mentioned in sample 52 Sessionless Load Balancing Between 3 Endpoints.

The above configuration routes a cloned copy of a message to each recipient defined within the dynamic recipient list. Each recipient will respond back with a stock quote. When all the responses appear to synapse, those resonses will be aggregated to form the resultant response which will be sent back to the client.

To test this, invoke the client as follows:

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

If you sent your client request through a TCP based conversation monitoring tool such as TCPMon, you will notice the structure of the aggregated response message.

  • No labels