Package io.namastack.outbox.retry
Class ExponentialBackoffRetryPolicy
-
- All Implemented Interfaces:
-
io.namastack.outbox.retry.OutboxRetryPolicy
public final class ExponentialBackoffRetryPolicy implements OutboxRetryPolicy
Retry policy that implements exponential backoff with configurable parameters.
This policy increases the delay between retries exponentially, starting with an initial delay and multiplying by a backoff multiplier for each retry, up to a maximum delay.
- Since:
0.1.0
Roland Beisel
-
-
Constructor Summary
Constructors Constructor Description ExponentialBackoffRetryPolicy(Duration initialDelay, Duration maxDelay, Double backoffMultiplier)
-
Method Summary
-
-
Method Detail
-
shouldRetry
Boolean shouldRetry(Throwable exception)
Always returns true, indicating that retries should be attempted.
- Parameters:
exception- The exception that occurred- Returns:
Always true
-
nextDelay
Duration nextDelay(Integer retryCount)
Calculates the next delay using exponential backoff.
The delay is calculated as: initialDelay * (backoffMultiplier ^ retryCount) The result is capped at the maximum delay.
- Parameters:
retryCount- The current retry count- Returns:
Calculated delay duration, capped at maxDelay
-
-
-
-