Package org.keycloak.events.outbox
Class OutboxBackoff
java.lang.Object
org.keycloak.events.outbox.OutboxBackoff
Computes the exponential-backoff next-attempt timestamp for a failed
outbox delivery, and decides when a row has exhausted its budget and
should be transitioned to
DEAD_LETTER.
The backoff curve and the dead-letter threshold are configured per
OutboxConfig.backoff(), so different consumers (SSF push,
webhooks, ...) can pick curves that match their delivery semantics.
A small uniform jitter (±25% of the base delay) is mixed in on each computation so a flood of rows enqueued in the same tick don't all wake up to retry in the same millisecond — spreading the retry load in clustered deployments and across receivers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionDefault HTTP-push curve — sensible for receivers that respond to an HTTP POST.static final intprotected final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected DurationbaseDelayFor(int attempts) computeNextAttemptAt(Instant now, int attempts) Computes thenext_attempt_attimestamp for a row whoseattemptscounter has just been incremented to the given value after a failure.getCurve()intSum of the curve up tomaxAttemptsentries — the worst-case time a row can spend in PENDING under the natural retry path before exhausting attempts.booleanisExhausted(int attempts) Returnstrueif the row has burned through its retry budget and should be transitioned toDEAD_LETTERinstead of scheduling another attempt.
-
Field Details
-
DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_MAX_ATTEMPTS- See Also:
-
DEFAULT_HTTP_PUSH_CURVE
Default HTTP-push curve — sensible for receivers that respond to an HTTP POST. Consumers with different delivery semantics (e.g. internal queue write) should provide their own. -
maxAttempts
protected final int maxAttempts -
curve
-
-
Constructor Details
-
OutboxBackoff
public OutboxBackoff() -
OutboxBackoff
-
-
Method Details
-
isExhausted
public boolean isExhausted(int attempts) Returnstrueif the row has burned through its retry budget and should be transitioned toDEAD_LETTERinstead of scheduling another attempt.- Parameters:
attempts- the value ofattemptsafter the current failure has been accounted for.
-
computeNextAttemptAt
Computes thenext_attempt_attimestamp for a row whoseattemptscounter has just been incremented to the given value after a failure. Callers should only invoke this whenisExhausted(int)returns false. -
getMaxNaturalRetryDuration
Sum of the curve up tomaxAttemptsentries — the worst-case time a row can spend in PENDING under the natural retry path before exhausting attempts. Operators tuningpendingMaxAgebackstops should keep that value comfortably above this floor. -
baseDelayFor
-
getCurve
-
getMaxAttempts
public int getMaxAttempts()
-