Class RedisOutboxRetentionWorker

java.lang.Object
com.aim2be.platform.outbox.redis.RedisOutboxRetentionWorker

public class RedisOutboxRetentionWorker extends Object
SENT-entry retention sweep (refinement #9). A single Hash accumulating SENT entries forever would OOM under noeviction (and noeviction turns that into a fail-closed write error — see RedisDurabilityValidator), so this worker HDELs SENT entries older than the retention window, giving downstream audit/billing pipelines a window to reconcile first.

FAILED entries are NEVER reaped here (refinement #3) — they are operator-owned; purge happens only after an explicit operator ack via a separate admin path. The status re-check is inside retention-delete-sent.lua, so a concurrent operator re-arm (SENT→PENDING) between the HSCAN snapshot and the delete cannot reap a re-armed entry.

Iteration uses HSCAN (cursor-based, non-blocking) so a large Hash is not scanned in one blocking call; the sweep stops at retention.batch-size deletions per tick to bound per-tick cost.

  • Constructor Details

    • RedisOutboxRetentionWorker

      public RedisOutboxRetentionWorker(org.springframework.data.redis.core.StringRedisTemplate redis, RedisOutboxScripts scripts, RedisOutboxKeys keys, com.fasterxml.jackson.databind.ObjectMapper objectMapper, RedisOutboxProperties.Retention config, RedisOutboxMetrics metrics)
      Parameters:
      redis - Redis template (HSCAN + the delete EVAL)
      scripts - Lua scripts (status-guarded retention delete)
      keys - the hash-tagged key set (the entries Hash)
      objectMapper - JSON decoder for the scanned entries
      config - retention config (window, batch size)
      metrics - metrics binder (retention-deleted counter)
  • Method Details

    • sweepSentEntries

      @Scheduled(fixedDelayString="${im2be.outbox.redis.retention.interval-ms:3600000}") public void sweepSentEntries()
      Scheduled retention sweep. Cadence governed by im2be.outbox.redis.retention.interval-ms.