Class RedisOutboxScripts

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

public final class RedisOutboxScripts extends Object
Loads + holds the Lua RedisScript singletons the backend executes.

Per the Spring Data Redis scripting guide (https://docs.spring.io/spring-data/redis/reference/redis/scripting.html, verified 2026-05-28) a RedisScript should be configured ONCE in the application context so its SHA1 is computed a single time; the executor then attempts EVALSHA first and transparently falls back to EVAL when the script is not yet cached server-side. Constructing a fresh script per call would re-hash on every invocation — hence this holder.

The scripts live under META-INF/scripts/*.lua so the .lua source is auditable + diffable independently of the Java that invokes it (the fail-closed write ordering of refinement #1 is a property of the .lua, not of the call site).

Result types follow the Spring Data Redis supported set (Long, Boolean, List, String):

  • Constructor Details

    • RedisOutboxScripts

      public RedisOutboxScripts()
      Loads every script from the classpath. Construction is the single SHA1 computation point (the scripts are cached as instance fields).
  • Method Details

    • enqueue

      public org.springframework.data.redis.core.script.RedisScript<Long> enqueue()
      Returns:
      the enqueue-one-PENDING script (refinements #1, #12).
    • markSent

      public org.springframework.data.redis.core.script.RedisScript<Long> markSent()
      Returns:
      the PENDING→SENT transition script (status-guarded).
    • markFailure

      public org.springframework.data.redis.core.script.RedisScript<List> markFailure()
      Returns:
      the failure-attempt script (re-score #5, park-to-FAILED #3); returns [applied, parked]
    • lockRenew

      public org.springframework.data.redis.core.script.RedisScript<Long> lockRenew()
      Returns:
      the compare-and-renew lock script (refinement #4).
    • lockRelease

      public org.springframework.data.redis.core.script.RedisScript<Long> lockRelease()
      Returns:
      the compare-and-delete lock-release script (refinement #4).
    • retentionDeleteSent

      public org.springframework.data.redis.core.script.RedisScript<Long> retentionDeleteSent()
      Returns:
      the status-guarded SENT-retention HDEL script (refinement #9).
    • repairReconcile

      public org.springframework.data.redis.core.script.RedisScript<Long> repairReconcile()
      Returns:
      the zset/hash reconciliation script (refinement #10).
    • expiryDecide

      public org.springframework.data.redis.core.script.RedisScript<String> expiryDecide()
      Returns:
      the expiry due-time decision script (refinement #2 primitive).