This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata


This sample demonstrates message routing to a set of dynamic endpoints and aggregate responses.


For a list of prerequisites, see Prerequisites to Start the ESB Samples.

Building the sample

The XML configuration for this sample is as follows: 

<definitions xmlns="">
   <sequence name="errorHandler">
      <makefault response="true">
         <code xmlns:tns="" value="tns:Receiver" />
         <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER." />
      <send />
   <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')" />
      <drop />
   <sequence name="main" onError="errorHandler">
         <property name="EP_LIST" value="http://localhost:9001/services/SimpleStockQuoteService,http://localhost:9002/services/SimpleStockQuoteService,http://localhost:9003/services/SimpleStockQuoteService"/>	
                  <endpoints value="{get-property('EP_LIST')}" max-cache="20" />
        <!--Aggregate responses-->
           <onComplete xmlns:m0="http://services.samples"
             <log level="full"/>

This configuration file  synapse_sample_62.xml is available in the <ESB_HOME>/repository/samples directory.

To build the sample

  1. Start the ESB with the sample 62 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.

    The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."

  2. 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 .

  3. Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.

Executing the sample

The sample client used here is the Stock Quote Client, which can operate in several modes. For further details on this sample client and its operation modes, see Stock Quote Client.

To execute the sample client

  • Run the following command from the <ESB_HOME>/samples/axis2Client directory:

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

Analyzing the output

When you have a look at the   synapse_sample_62.xml configuration,  you will see that it routes a cloned copy of a message to each recipient defined within the dynamic recipient list , and that each recipient responds back with a stock quote. When all the responses reach the ESB, the responses are aggregated to form the final response, which will be sent back to the client.

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

  • No labels