org.apache.synapse.endpoints
Class SALoadbalanceEndpoint
java.lang.Object
org.apache.synapse.FaultHandler
org.apache.synapse.endpoints.AbstractEndpoint
org.apache.synapse.endpoints.LoadbalanceEndpoint
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.
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 |
SALoadbalanceEndpoint
public SALoadbalanceEndpoint()
init
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
- Overrides:
init
in class LoadbalanceEndpoint
- Parameters:
synapseEnvironment
- SynapseEnvironment to be used for initialization
send
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
- Overrides:
send
in class LoadbalanceEndpoint
- Parameters:
synCtx
- MessageContext to be sent.
getDispatcher
public Dispatcher getDispatcher()
setDispatcher
public void setDispatcher(Dispatcher dispatcher)
onChildEndpointFail
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
- Overrides:
onChildEndpointFail
in class LoadbalanceEndpoint
- Parameters:
endpoint
- Failed endpoint.synCtx
- MessageContext of the failed message.
getSessionTimeout
public long getSessionTimeout()
setSessionTimeout
public void setSessionTimeout(long sessionTimeout)
Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.