Class OutboxDrainerTask

java.lang.Object
org.keycloak.events.outbox.OutboxDrainerTask
All Implemented Interfaces:
KeycloakSessionTask, ScheduledTask

public class OutboxDrainerTask extends Object implements ScheduledTask
Drains the generic outbox for one registered entryKind: locks due PENDING rows, hands them off to the kind's OutboxDeliveryHandler, and transitions each row based on the returned OutboxDeliveryOutcome.

One drainer instance per registered kind. Each is wrapped in a ClusterAwareScheduledTaskRunner at scheduling time so in an HA deployment only one node drains a given kind per interval, even though every node schedules the timer.

Concurrency within a single tick is cheap because rows are locked PESSIMISTIC_WRITE via FOR UPDATE SKIP LOCKED by the store, and each row is transitioned to a terminal state (DELIVERED / back to PENDING with a future next_attempt_at / DEAD_LETTER) before the transaction commits.

Per-tick housekeeping after the drain pass: