...
Code Block | ||
---|---|---|
| ||
<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="main" onError="errorHandler"> <in> <send> <endpoint> <failover> <endpoint> <address uri="http://localhost:9001/services/LBService1"> <enableAddressing/> <suspendDurationOnFailure>60</suspendDurationOnFailure> </address> </endpoint> <endpoint> <address uri="http://localhost:9002/services/LBService1"> <enableAddressing/> <suspendDurationOnFailure>60</suspendDurationOnFailure> </address> </endpoint> <endpoint> <address uri="http://localhost:9003/services/LBService1"> <enableAddressing/> <suspendDurationOnFailure>60</suspendDurationOnFailure> </address> </endpoint> </failover> </endpoint> </send><drop/> </in> <out> <!-- Send the messages where they have been sent (i.e. implicit To EPR) --> <send/> </out> </sequence> <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 ESB with sample configuration 53:
wso2esb-samples.sh -sn 53
- Deploy the
LoadbalanceFailoverService
and start three instances of sample Axis2 server as mentioned in sample 52.
Above configuration sends messages with the failover behavior. Initially the server at port 9001 is treated as primary and other two are treated as back ups. Messages are always directed only to the primary server. If the primary server has failed, next listed server is selected as the primary. Thus, messages are sent successfully as long as there is at least one active server. To test this, run the loadbalancefailover client to send infinite requests as follows:
...