Class EsbMessageDedupe

java.lang.Object
com.kingsrook.qqq.esb.outbox.EsbMessageDedupe

public final class EsbMessageDedupe extends Object
Idempotent triggers: which messages a trigger already processed, kept in the processed-message table (see EsbDedupeConfig). Why a table, not a per-node cache: a redelivery after a broker failover (or after a lost commit) often lands on a different node than the one that processed the message, and a restarted node has an empty cache - so only a shared, durable record can answer "was this processed?". A cache in front would only help the rare duplicate, while every message still needs the database check, so there is none. The unique (trigger, message id) key makes the record correct even when two nodes race. The trigger runner checks before running (skipping processed messages), and records after a successful run, before acknowledging - so a failure between the two can still run a message twice (at-least-once), but a redelivered message whose run was recorded never runs again.
  • Method Details

    • getEnabledConfig

      public static EsbDedupeConfig getEnabledConfig(QInstance qInstance)
      The instance's dedupe settings, if dedupe is enabled - else null.
    • findProcessed

      public static Set<String> findProcessed(EsbDedupeConfig config, String triggerName, Collection<String> messageKeys) throws QException
      Of the given message keys, those the trigger already processed. Throws if the table can't be read (the caller must not run the messages then).
      Throws:
      QException
    • recordProcessed

      public static void recordProcessed(EsbDedupeConfig config, String triggerName, Collection<String> messageKeys)
      Record that the trigger processed these messages. Never throws: a failure (e.g., another node recorded one first) is logged - the run has already happened.