Apache CXF API

Class LoadDistributorTargetSelector

  extended by org.apache.cxf.endpoint.AbstractConduitSelector
      extended by org.apache.cxf.clustering.FailoverTargetSelector
          extended by org.apache.cxf.clustering.LoadDistributorTargetSelector
All Implemented Interfaces:
Closeable, ConduitSelector

public class LoadDistributorTargetSelector
extends FailoverTargetSelector

jtalbut The LoadDistributorTargetSelector attempts to do the same job as the FailoverTargetSelector, but to choose an alternate target on every request rather than just when a fault occurs. The LoadDistributorTargetSelector uses the same FailoverStrategy interface as the FailoverTargetSelector, but has a few significant limitations: 1. Because the LoadDistributorTargetSelector needs to maintain a list of targets between calls it has to obtain that list without reference to a Message. Most FailoverStrategy classes can support this for addresses, but it cannot be supported for endpoints. If the list of targets cannot be obtained without reference to a Message then the list will still be obtained but it will be specific to the Message and thus discarded after this message has been processed. As a consequence, if the strategy chosen is a simple sequential one the first item in the list will be chosen every time. Conclusion: Be aware that if you are working with targets that are dependent on the Message the process will be less efficient and that the SequentialStrategy will not distribute the load at all. 2. The AbstractStaticFailoverStrategy base class excludes the 'default' endpoint from the list of alternate endpoints. If alternate endpoints (as opposed to alternate addresses) are to be used you should probably ensure that your FailoverStrategy overrides getAlternateEndpoints and calls getEndpoints with acceptCandidatesWithSameAddress = true.

Nested Class Summary
Nested classes/interfaces inherited from class org.apache.cxf.clustering.FailoverTargetSelector
FailoverTargetSelector.InvocationContext, FailoverTargetSelector.InvocationKey
Field Summary
Fields inherited from class org.apache.cxf.clustering.FailoverTargetSelector
failoverStrategy, inProgress
Fields inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
endpoint, KEEP_CONDUIT_ALIVE, selectedConduit
Constructor Summary
          Normal constructor.
LoadDistributorTargetSelector(Conduit c)
          Constructor, allowing a specific conduit to override normal selection.
Method Summary
protected  Endpoint getFailoverTarget(Exchange exchange, FailoverTargetSelector.InvocationContext invocation)
          Get the failover target endpoint, if a suitable one is available.
protected  Logger getLogger()
 boolean isFailover()
protected  boolean requiresFailover(Exchange exchange)
          Check if the exchange is suitable for a failover.
 Conduit selectConduit(Message message)
          Called when a Conduit is actually required.
 void setFailover(boolean failover)
Methods inherited from class org.apache.cxf.clustering.FailoverTargetSelector
complete, getDelayBetweenRetries, getStrategy, overrideAddressProperty, prepare, setStrategy
Methods inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
close, getEndpoint, getSelectedConduit, replaceEndpointAddressPropertyIfNeeded, setEndpoint
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public LoadDistributorTargetSelector()
Normal constructor.


public LoadDistributorTargetSelector(Conduit c)
Constructor, allowing a specific conduit to override normal selection.

c - specific conduit
Method Detail


public boolean isFailover()


public void setFailover(boolean failover)


protected Logger getLogger()
getLogger in class FailoverTargetSelector
the logger to use


public Conduit selectConduit(Message message)
Called when a Conduit is actually required.

Specified by:
selectConduit in interface ConduitSelector
selectConduit in class FailoverTargetSelector
message -
the Conduit to use for mediation of the message


protected Endpoint getFailoverTarget(Exchange exchange,
                                     FailoverTargetSelector.InvocationContext invocation)
Get the failover target endpoint, if a suitable one is available.

getFailoverTarget in class FailoverTargetSelector
exchange - the current Exchange
invocation - the current InvocationContext
a failover endpoint if one is available Note: The only difference between this and the super implementation is that the current (failed) address is removed from the list set of alternates, it could be argued that that change should be in the super implementation but I'm not sure of the impact.


protected boolean requiresFailover(Exchange exchange)
Description copied from class: FailoverTargetSelector
Check if the exchange is suitable for a failover.

requiresFailover in class FailoverTargetSelector
exchange - the current Exchange
boolean true if a failover should be attempted

Apache CXF API

Apache CXF