This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Objective: Demonstrate the use of Iterate mediator to split the messages in to parts and process them asynchronously and then aggregate the responses coming in to ESB.

<definitions xmlns="http://ws.apache.org/ns/synapse">

    <proxy name="SplitAggregateProxy">
        <target>
            <inSequence>
                <iterate expression="//m0:getQuote/m0:request" preservePayload="true"
                         attachPath="//m0:getQuote"
                         xmlns:m0="http://services.samples">
                    <target>
                        <sequence>
                            <send>
                                <endpoint>
                                    <address
                                        uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                                </endpoint>
                            </send>
                        </sequence>
                    </target>
                </iterate>
            </inSequence>
            <outSequence>
                <aggregate>
                    <onComplete expression="//m0:getQuoteResponse"
                                xmlns:m0="http://services.samples">
                        <send/>
                    </onComplete>
                </aggregate>
            </outSequence>
        </target>
    </proxy>
</definitions>

Prerequisites:

  • Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.
  • Start ESB with the sample configuration 400 (i.e. wso2ei-samples -sn 400).

In this sample, the message sent to ESB has embedded with a number of elements of the same type in one message. When ESB received this message it will iterate through those elements and then sent to the specified endpoint. When all the responses appear in to ESB then those messages will be aggregated to form the resultant response and sent back to the client.

Invoke the client as follows.

ant stockquote -Daddurl=http://localhost:8280/services/SplitAggregateProxy -Ditr=4
  • No labels