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 of this interface should be immutable. To implement strategies where
the delay uses different parameters on each subsequent retry (such as exponential
backoff), the strategy should return a new instance of its own class in
RetryDelayStrategy.Result.getNext(), rather than modifying the state of the
existing instance. This makes it easy for EventSource to reset to the original delay
state when appropriate by simply reusing the original instance.
- Since:
- 4.0.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract RetryDelayStrategy.Resultapply(long baseDelayMillis) Applies the strategy to compute the appropriate retry delay.static DefaultRetryDelayStrategyReturns the default implementation, configured to use the default backoff and jitter.
-
Constructor Details
-
RetryDelayStrategy
public RetryDelayStrategy()
-
-
Method Details
-
apply
Applies the strategy to compute the appropriate retry delay.- Parameters:
baseDelayMillis- the initial configured base delay as set byEventSource.Builder.retryDelay(long, java.util.concurrent.TimeUnit)- Returns:
- the computed delay
-
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.
-