Class ExponentialBackoffRetryPolicy

java.lang.Object
outbox.dispatch.ExponentialBackoffRetryPolicy
All Implemented Interfaces:
RetryPolicy

public final class ExponentialBackoffRetryPolicy extends Object implements 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 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: RetryPolicy
      Computes the delay in milliseconds before the next retry attempt.
      Specified by:
      computeDelayMs in interface RetryPolicy
      Parameters:
      attempts - the number of attempts so far (1-based)
      Returns:
      delay in milliseconds (non-negative)