Package com.aim2be.platform.outbox.redis
Class RedisOutboxRepairWorker
java.lang.Object
com.aim2be.platform.outbox.redis.RedisOutboxRepairWorker
zset/hash reconciliation sweep (refinement #10). The two index structures —
the
:entries Hash (durable record) + the :pending sorted-set
(poller index) — can diverge after a mid-script crash (refinement #1: a Lua
runtime error does NOT roll back earlier writes). This worker reconciles two
classes of inconsistency:
- orphan zset member — a
:pendingmember with NO:entriesfield. The poller's HMGET returns nil and skips it forever; the member lingers. Repair: ZREM it (only when the Hash field is STILL absent — re-checked inrepair-reconcile.lua). - orphan Hash entry — an
:entriesfield withstatus=PENDINGbut NO:pendingmember. The poller scans:pending, so it never sees it → never relayed. Repair: re-ZADD it with score=now (only when STILL PENDING and STILL un-indexed).
The two snapshots (HSCAN entries + ZSCAN pending) are taken
at slightly different instants, so a candidate could be stale by the time the
repair runs; the repair-reconcile.lua script re-checks the live state
and no-ops if the inconsistency has resolved itself — so the worker is safe to
run even while the poller + relay are active.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordPer-class repair counts from one reconciliation pass. -
Constructor Summary
ConstructorsConstructorDescriptionRedisOutboxRepairWorker(org.springframework.data.redis.core.StringRedisTemplate redis, RedisOutboxScripts scripts, RedisOutboxKeys keys, com.fasterxml.jackson.databind.ObjectMapper objectMapper, RedisOutboxMetrics metrics) -
Method Summary
-
Constructor Details
-
RedisOutboxRepairWorker
public RedisOutboxRepairWorker(org.springframework.data.redis.core.StringRedisTemplate redis, RedisOutboxScripts scripts, RedisOutboxKeys keys, com.fasterxml.jackson.databind.ObjectMapper objectMapper, RedisOutboxMetrics metrics) - Parameters:
redis- Redis template (HSCAN/ZSCAN + the reconcile EVAL)scripts- Lua scripts (the reconcile script)keys- the hash-tagged key setobjectMapper- JSON decoder for the scanned entriesmetrics- metrics binder (per-class repair counter)
-
-
Method Details
-
reconcile
@Scheduled(fixedDelayString="${im2be.outbox.redis.repair.interval-ms:900000}") public void reconcile()Scheduled repair sweep. Cadence governed byim2be.outbox.redis.repair.interval-ms.
-