Class RedisOutboxKeys

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

public final class RedisOutboxKeys extends Object
Derives the four co-located Redis keys the backend touches, all sharing the configured hash-tag prefix so a single Lua EVAL stays single-slot in cluster mode (refinement #8 — cluster-safe by construction; the dev cluster is standalone today, but tagging now is free and removes a future migration).

Key layout for the default prefix {identity:outbox}:

  • {identity:outbox}:entries — Hash, field = event_id (UUID string), value = RedisOutboxEntry JSON.
  • {identity:outbox}:pending — sorted-set, member = event_id, score = nextAttemptAt epoch-ms (refinement #5).
  • {identity:outbox}:expiry-due — sorted-set, member = ticket-id, score = expiresAt epoch-ms (refinement #2 primitive; the identity-side due-time worker that consumes it is Phase 1).
  • {identity:outbox}:lock — string, single-writer poller lock holding an owner token, released via compare-and-delete (refinement #4).

Redis Cluster hashes only the substring inside the first {...} when assigning a slot, so every key above lands in the same slot — the EVAL touching :entries + :pending (+ :expiry-due) is a legal single-slot multi-key script.

  • Constructor Details

    • RedisOutboxKeys

      public RedisOutboxKeys(String keyPrefix)
      Builds the key set from the configured hash-tag-bearing prefix.
      Parameters:
      keyPrefix - the prefix INCLUDING its hash-tag braces (validated by RedisOutboxProperties.getKeyPrefix()); never null
  • Method Details

    • entries

      public String entries()
      Returns:
      the Hash key (event_id → JSON entry).
    • pending

      public String pending()
      Returns:
      the pending sorted-set key (event_id → nextAttemptAt score).
    • expiryDue

      public String expiryDue()
      Returns:
      the expiry-due sorted-set key (ticket_id → expiresAt score).
    • lock

      public String lock()
      Returns:
      the single-writer poller lock key.