Class RetryStrategy

All Implemented Interfaces:
FailoverStrategy, PerInvocationFailoverStrategy

public class RetryStrategy extends SequentialStrategy implements 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 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: AbstractStaticFailoverStrategy
      Get the alternate endpoints for this invocation.
      Specified by:
      getAlternateEndpoints in interface FailoverStrategy
      Overrides:
      getAlternateEndpoints in class AbstractStaticFailoverStrategy
      Parameters:
      exchange - the current Exchange
      Returns:
      a List of alternate endpoints if available
    • getNextAlternate

      protected <T> T getNextAlternate(List<T> alternates)
      Description copied from class: SequentialStrategy
      Get next alternate endpoint.
      Overrides:
      getNextAlternate in class SequentialStrategy
      Parameters:
      alternates - non-empty List of alternate endpoints
      Returns:
      the next endpoint or null in case there are no more alternates
    • stillTheSameAddress

      protected boolean stillTheSameAddress(org.apache.cxf.message.Exchange exchange)
      Exchange-aware variant; delegates to stillTheSameAddress() so subclasses may override either form.
    • stillTheSameAddress

      protected boolean stillTheSameAddress()
    • newStrategy

      public FailoverStrategy newStrategy()
      Returns a new RetryStrategy with 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:
      newStrategy in interface PerInvocationFailoverStrategy
    • setMaxNumberOfRetries

      public void setMaxNumberOfRetries(int maxNumberOfRetries)
    • getMaxNumberOfRetries

      public int getMaxNumberOfRetries()