Package org.apache.cxf.clustering
Class RetryStrategy
java.lang.Object
org.apache.cxf.clustering.AbstractStaticFailoverStrategy
org.apache.cxf.clustering.SequentialStrategy
org.apache.cxf.clustering.RetryStrategy
- All Implemented Interfaces:
FailoverStrategy,PerInvocationFailoverStrategy
Retry strategy that retries the same endpoint for a configured number of
attempts before advancing to the next alternate (CXF-2036).
This class implements PerInvocationFailoverStrategy: when used
via FailoverTargetSelector, a fresh instance is created per
top-level invocation through newStrategy(), so the shared
singleton bean is never mutated and concurrent invocations are fully
isolated (CXF-9213). The per-invocation instance carries its own retry
counter as a plain instance field
Subclasses that accumulate cross-invocation state (e.g. call counters)
should override newStrategy() to return a delegate that writes
that state back to the shared instance while keeping its own retry counter.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<org.apache.cxf.endpoint.Endpoint> getAlternateEndpoints(org.apache.cxf.message.Exchange exchange) Get the alternate endpoints for this invocation.intprotected <T> TgetNextAlternate(List<T> alternates) Get next alternate endpoint.Returns a newRetryStrategywith the same configuration but a zeroed counter.voidsetMaxNumberOfRetries(int maxNumberOfRetries) protected booleanprotected booleanstillTheSameAddress(org.apache.cxf.message.Exchange exchange) Exchange-aware variant; delegates tostillTheSameAddress()so subclasses may override either form.Methods inherited from class org.apache.cxf.clustering.AbstractStaticFailoverStrategy
getAlternateAddresses, getDelayBetweenRetries, getEndpoints, getLogLevel, selectAlternateAddress, selectAlternateEndpoint, setAlternateAddresses, setDelayBetweenRetries
-
Constructor Details
-
RetryStrategy
public RetryStrategy()
-
-
Method Details
-
getAlternateEndpoints
public List<org.apache.cxf.endpoint.Endpoint> getAlternateEndpoints(org.apache.cxf.message.Exchange exchange) Description copied from class:AbstractStaticFailoverStrategyGet the alternate endpoints for this invocation.- Specified by:
getAlternateEndpointsin interfaceFailoverStrategy- Overrides:
getAlternateEndpointsin classAbstractStaticFailoverStrategy- Parameters:
exchange- the current Exchange- Returns:
- a List of alternate endpoints if available
-
getNextAlternate
Description copied from class:SequentialStrategyGet next alternate endpoint.- Overrides:
getNextAlternatein classSequentialStrategy- Parameters:
alternates- non-empty List of alternate endpoints- Returns:
- the next endpoint or
nullin case there are no more alternates
-
stillTheSameAddress
protected boolean stillTheSameAddress(org.apache.cxf.message.Exchange exchange) Exchange-aware variant; delegates tostillTheSameAddress()so subclasses may override either form. -
stillTheSameAddress
protected boolean stillTheSameAddress() -
newStrategy
Returns a newRetryStrategywith the same configuration but a zeroed counter. Subclasses that need to accumulate state on the shared instance should override this method and return a delegating wrapper.- Specified by:
newStrategyin interfacePerInvocationFailoverStrategy
-
setMaxNumberOfRetries
public void setMaxNumberOfRetries(int maxNumberOfRetries) -
getMaxNumberOfRetries
public int getMaxNumberOfRetries()
-