Class SALoadbalanceEndpoint

  extended by org.apache.synapse.FaultHandler
      extended by org.apache.synapse.endpoints.AbstractEndpoint
          extended by org.apache.synapse.endpoints.LoadbalanceEndpoint
              extended by org.apache.synapse.endpoints.SALoadbalanceEndpoint
All Implemented Interfaces:
Endpoint, ManagedLifecycle, Nameable, PropertyInclude, SynapseArtifact

public class SALoadbalanceEndpoint
extends LoadbalanceEndpoint

SALoadbalanceEndpoint supports session affinity based load balancing. Each of this endpoint maintains a list of dispatchers. These dispatchers will be updated for both request (for client initiated sessions) and response (for server initiated sessions). Once updated, each dispatcher will check if has already encountered that session. If not, it will update the session -> endpoint map. To update sessions for response messages, all SALoadbalanceEndpoint objects are kept in a global property. When a message passes through SALoadbalanceEndpoints, each endpoint appends its "Synapse unique ID" to the operation context. Once the response for that message arrives, response sender checks first endpoint of the endpoint sequence from the operation context and get that endpoint from the above mentioned global property. Then it will invoke updateSession(...) method of that endpoint. After that, each endpoint will call updateSession(...) method of their appropriate child endpoint, so that all the sending endpoints for the session will be updated.

This endpoint gets the target endpoint first from the dispatch manager, which will ask all listed dispatchers for a matching session. If a matching session is found it will just invoke the send(...) method of that endpoint. If not it will find an endpoint using the load balancing policy and send to that endpoint.

Field Summary
Fields inherited from class org.apache.synapse.endpoints.AbstractEndpoint
anonymous, errorHandler, fileName, initialized, isClusteringEnabled, log, trace
Constructor Summary
Method Summary
 Dispatcher getDispatcher()
 long getSessionTimeout()
 void init(SynapseEnvironment synapseEnvironment)
          This method should implement the initialization of the implemented parts of the configuration.
 void onChildEndpointFail(Endpoint endpoint, MessageContext synCtx)
          It is logically incorrect to failover a session affinity endpoint after the session has started.
 void send(MessageContext synCtx)
          Sends the message context according to an endpoint specific behavior.
 void setDispatcher(Dispatcher dispatcher)
 void setSessionTimeout(long sessionTimeout)
Methods inherited from class org.apache.synapse.endpoints.LoadbalanceEndpoint
destroy, getAlgorithm, getMembers, getNextChild, isFailover, readyToSend, setAlgorithm, setFailover, setMembers, startApplicationMembershipTimer
Methods inherited from class org.apache.synapse.endpoints.AbstractEndpoint
addProperties, addProperty, evaluateProperties, getChildren, getContext, getDefinition, getDescription, getErrorHandler, getFileName, getMetricsMBean, getName, getParentEndpoint, getProperties, getProperty, handleException, handleException, informFailure, isAnonymous, isInitialized, isLeafEndpoint, isRetryDisabled, isSuspendFault, isTimeout, isTraceOn, isTraceOrDebugOn, logOnChildEndpointFail, onFault, onSuccess, prepareForEndpointStatistics, removeProperty, setAnonymous, setChildren, setDefinition, setDescription, setEnableMBeanStats, setErrorHandler, setErrorOnMessage, setFileName, setName, setParentEndpoint, toString, traceOrDebug
Methods inherited from class org.apache.synapse.FaultHandler
getStackTrace, handleFault, handleFault
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public SALoadbalanceEndpoint()
Method Detail


public void init(SynapseEnvironment synapseEnvironment)
Description copied from interface: ManagedLifecycle
This method should implement the initialization of the implemented parts of the configuration.

Specified by:
init in interface ManagedLifecycle
init in class LoadbalanceEndpoint
synapseEnvironment - SynapseEnvironment to be used for initialization


public void send(MessageContext synCtx)
Description copied from interface: Endpoint
Sends the message context according to an endpoint specific behavior.

Specified by:
send in interface Endpoint
send in class LoadbalanceEndpoint
synCtx - MessageContext to be sent.


public Dispatcher getDispatcher()


public void setDispatcher(Dispatcher dispatcher)


public void onChildEndpointFail(Endpoint endpoint,
                                MessageContext synCtx)
It is logically incorrect to failover a session affinity endpoint after the session has started. If we redirect a message belonging to a particular session, new endpoint is not aware of the session. So we can't handle anything more at the endpoint level. Therefore, this method just deactivate the failed endpoint and give the fault to the next fault handler.

But if the session has not started (i.e. first message), the message will be resend by binding it to a different endpoint.

Specified by:
onChildEndpointFail in interface Endpoint
onChildEndpointFail in class LoadbalanceEndpoint
endpoint - Failed endpoint.
synCtx - MessageContext of the failed message.


public long getSessionTimeout()


public void setSessionTimeout(long sessionTimeout)

Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.