Package io.namastack.outbox.retry
Class JitteredRetryPolicy
-
- All Implemented Interfaces:
-
io.namastack.outbox.retry.OutboxRetryPolicy
public final class JitteredRetryPolicy implements OutboxRetryPolicy
Retry policy that adds random jitter to a base retry policy.
This policy wraps another retry policy and adds random jitter to the delay to help avoid thundering herd problems when multiple instances retry at the same time.
- Since:
0.1.0
Roland Beisel
-
-
Constructor Summary
Constructors Constructor Description JitteredRetryPolicy(OutboxRetryPolicy basePolicy, Duration jitter)
-
Method Summary
-
-
Constructor Detail
-
JitteredRetryPolicy
JitteredRetryPolicy(OutboxRetryPolicy basePolicy, Duration jitter)
- Parameters:
basePolicy- The underlying retry policy to add jitter tojitter- Maximum jitter duration to add
-
-
Method Detail
-
shouldRetry
Boolean shouldRetry(Throwable exception)
Delegates the retry decision to the base policy.
- Parameters:
exception- The exception that occurred- Returns:
True if the base policy says to retry
-
-
-
-