Class OutboxCleanupTask

java.lang.Object
org.keycloak.events.outbox.OutboxCleanupTask
All Implemented Interfaces:
Runnable

public class OutboxCleanupTask extends Object implements Runnable
Background cleanup task that drains outbox rows owned by a removed realm or owner (e.g. receiver client). Runs in a single bounded transaction so the admin's original removal transaction can commit immediately instead of carrying a six-digit DELETE on its back.

Submitted by a feature's lifecycle listener (e.g. SSF's RealmRemovedEvent / ClientRemovedEvent handler) to a Keycloak-managed executor. The task itself opens a fresh session via KeycloakModelUtils.runJobInTransaction(org.keycloak.models.KeycloakSessionFactory, org.keycloak.models.KeycloakSessionTask) so it doesn't inherit the caller's transaction or session lifecycle.

Crash safety: if the node running this task dies mid-flight, the remaining rows are orphaned. That's bounded by the pendingMaxAge backstop on the drainer for queued rows and by the configured retention windows for terminal rows — orphan rows eventually get swept either way.

  • Field Details

    • factory

      protected final org.keycloak.models.KeycloakSessionFactory factory
    • storeFactory

      protected final Function<org.keycloak.models.KeycloakSession,OutboxStore> storeFactory
    • entryKind

      protected final String entryKind
    • scope

      protected final OutboxCleanupTask.Scope scope
    • key

      protected final String key
  • Constructor Details

  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable