Package com.aim2be.platform.outbox.redis
Class RedisOutboxBackoff
java.lang.Object
com.aim2be.platform.outbox.redis.RedisOutboxBackoff
Exponential-backoff calculator for the failure re-score of the
:pending
sorted-set (refinement #5 — score by nextAttemptAt, not
createdAt, so a Kafka outage does not hot-loop the oldest entries).
The delay for a given attempt count is
min(base * 2^attempt, max). attempt is the entry's CURRENT
retries value (0 on the first failure → base; 1 → 2*base;
etc.). The shift is computed in long with an overflow guard so a large
attempt count saturates to max rather than wrapping negative.
Immutable + thread-safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongdelayMs(int attempt) static RedisOutboxBackofffrom(RedisOutboxProperties.Poller poller) Builds a backoff from the poller properties.
-
Constructor Details
-
RedisOutboxBackoff
public RedisOutboxBackoff(long baseMs, long maxMs) - Parameters:
baseMs- base delay in ms (attempt 0); must be ≥ 1maxMs- ceiling delay in ms; must be ≥baseMs
-
-
Method Details
-
from
Builds a backoff from the poller properties.- Parameters:
poller- the poller config carryingbackoffBaseMs+backoffMaxMs; nevernull- Returns:
- a configured backoff
-
delayMs
public long delayMs(int attempt) - Parameters:
attempt- the entry's current retries count (0-based; the first failure passes 0). Negative inputs are clamped to 0.- Returns:
- the backoff delay in ms, capped at
maxMs
-