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

    • Constructor Detail

      • SALoadbalanceEndpoint

        public SALoadbalanceEndpoint()
    • Method Detail

      • 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)