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 154: Load Balancing with Proxy Services

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: Load Balancing with Proxy Service.

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="LBProxy" transports="https http" startOnLoad="true">
        <target faultSequence="errorHandler">
            <inSequence>
                <send>
                    <endpoint>
                        <session type="simpleClientSession"/>
                        <loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
                            <endpoint>
                                <address uri="http://localhost:9001/services/LBService1">
                                    <enableAddressing/>
                                    <suspendDurationOnFailure>20</suspendDurationOnFailure>
                                </address>
                            </endpoint>
                            <endpoint>
                                <address uri="http://localhost:9002/services/LBService1">
                                    <enableAddressing/>
                                    <suspendDurationOnFailure>20</suspendDurationOnFailure>
                                </address>
                            </endpoint>
                            <endpoint>
                                <address uri="http://localhost:9003/services/LBService1">
                                    <enableAddressing/>
                                    <suspendDurationOnFailure>20</suspendDurationOnFailure>
                                </address>
                            </endpoint>
                        </loadbalance>
                    </endpoint>
                </send>
                <drop/>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
        <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_2.wsdl"/>
    </proxy>
    <sequence name="errorHandler">
        <makefault>
            <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
            <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
        </makefault>
        <header name="To" action="remove"/>
        <property name="RESPONSE" value="true"/>
        <send/>
    </sequence>
</definitions>
Prerequisites
  • Start the Synapse configuration numbered 154: wso2esb-samples.sh -sn 154
  • Start three instances of Axis2 server (on ports 9001, 9002, and 9003), and deploy the LBService to each of them. For more information, see Setting up the ESB Samples.

Run the client:

ant loadbalancefailover -Dmode=session -Dtrpurl=http://localhost:8280/services/LBProxy