Class RetryDelayStrategy
- Direct Known Subclasses:
DefaultRetryDelayStrategy
The default behavior, provided by DefaultRetryDelayStrategy, provides
customizable exponential backoff and jitter. Applications may also create their own
implementations of RetryDelayStrategy if they desire different behavior. It is
generally a best practice to use backoff and jitter, to avoid a reconnect storm
during a service interruption.
Implementations should be immutable. Each instance represents a single state in the
retry-delay sequence: getDelayMillis() returns the delay to use for the
impending retry, and getNext() returns the strategy instance to use for
the retry after that. Strategies with a base-delay concept may also implement
withBaseDelayMillis(long) to accept server-directed reconnection-time
overrides from the SSE retry: field.
- Since:
- 4.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultRetryDelayStrategyReturns the default implementation, configured to use the default backoff and jitter.abstract longReturns the retry delay this instance represents, in milliseconds.abstract RetryDelayStrategygetNext()Returns the strategy instance to use for the retry after this one.withBaseDelayMillis(long millis) Returns a fresh instance of this strategy with its base delay set to the given value and any backoff progression reset.
-
Constructor Details
-
RetryDelayStrategy
public RetryDelayStrategy()
-
-
Method Details
-
getDelayMillis
public abstract long getDelayMillis()Returns the retry delay this instance represents, in milliseconds. Pure and deterministic on a given instance.- Returns:
- the delay in milliseconds
- Since:
- 5.0.0
-
getNext
Returns the strategy instance to use for the retry after this one. Does not modify this instance.Strategies that never advance (e.g., a constant-delay strategy) return
this. Strategies with backoff progression return a new instance carrying the advanced state. Returningnullis treated as equivalent to returningthis.- Returns:
- the strategy to use next, or
nullto reuse this instance - Since:
- 5.0.0
-
withBaseDelayMillis
Returns a fresh instance of this strategy with its base delay set to the given value and any backoff progression reset.The default implementation returns
this. Strategies without a base-delay concept opt out of wire-directed base overrides by not implementing this method.- Parameters:
millis- the new base delay in milliseconds- Returns:
- a fresh instance with the given base, or
thisif the strategy does not honor base overrides - Since:
- 5.0.0
-
defaultStrategy
Returns the default implementation, configured to use the default backoff and jitter.You can call
DefaultRetryDelayStrategymethods on this instance to configure a strategy with different parameters.- Returns:
- the
DefaultRetryDelayStrategy.
-