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

Sample 60: Routing a Message to a Static List of Recipients

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

Objective: Demonstrate message routing to a set of static endpoints.

Prerequisites

Start ESB with the following sample configuration:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <sequence name="main" onError="errorHandler">
        <in>
            <send>
                <endpoint>
                    <!--List of Recipients (static)-->
                    <recipientlist>
                        <endpoint>
                            <address uri="http://localhost:9001/services/SimpleStockQuoteService"/>
                        </endpoint>
                        <endpoint>
                            <address uri="http://localhost:9002/services/SimpleStockQuoteService"/>
                        </endpoint>
						<endpoint>
                            <address uri="http://localhost:9003/services/SimpleStockQuoteService"/>
                        </endpoint>
                    </recipientlist>
                </endpoint>
            </send>
            <drop/>
        </in>
        <out>
            <log level="full"/>
            <drop/>
        </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 static recipient list. To test this, run the StockQuote client to send an out-only message as follows:

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

This client sends a request to the SimpleStockQuoteService through the ESB. ESB will create cloned copies of the message and route to the three endpoints mentioned in the configuration. SimpleStockQuoteService prints the details of the placed order. If you examine the console output of each server, you can see that requests are processed by the three servers as follows:

Accepted order #1 for : 15738 stocks of IBM at $ 185.51155223506518

Now shutdown MyServer1 and resend the request. You will observe that requests are still processed by MyServer2 and MyServer3.