Package outbox.dispatch
Class ExponentialBackoffRetryPolicy
java.lang.Object
outbox.dispatch.ExponentialBackoffRetryPolicy
- All Implemented Interfaces:
RetryPolicy
Retry policy using exponential backoff with jitter.
Delay formula: baseDelay * 2^(attempt-1), capped at maxDelay,
with random jitter in the range [0.5, 1.5).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcomputeDelayMs(int attempts) Computes the delay in milliseconds before the next retry attempt.
-
Constructor Details
-
ExponentialBackoffRetryPolicy
public ExponentialBackoffRetryPolicy(long baseDelayMs, long maxDelayMs) - Parameters:
baseDelayMs- base delay for the first retry (milliseconds)maxDelayMs- maximum delay cap (milliseconds)
-
-
Method Details
-
computeDelayMs
public long computeDelayMs(int attempts) Description copied from interface:RetryPolicyComputes the delay in milliseconds before the next retry attempt.- Specified by:
computeDelayMsin interfaceRetryPolicy- Parameters:
attempts- the number of attempts so far (1-based)- Returns:
- delay in milliseconds (non-negative)
-