Class Idempotent

java.lang.Object
com.babelqueue.idempotency.Idempotent

public final class Idempotent extends Object
Wraps a Handler so a message whose meta.id was already processed successfully is skipped instead of run again (ADR-0022) — the Java mirror of the PHP Idempotent::wrap, Go idempotency.Wrap, Python wrap, and Node Wrap helpers.

 Store store = new InMemoryStore();
 Handler handler = Idempotent.wrap(store, env -> process(env));
 

A previously-seen id returns early (so an adapter acks it and the broker stops redelivering); a throwing handler leaves the id unmarked so a redelivery runs it again (retry / dead-letter still apply); a message with no usable meta.id runs unchanged.

  • Method Details

    • wrap

      public static Handler wrap(Store store, Handler handler)
      Returns handler wrapped with dedupe on meta.id against store.
      Parameters:
      store - the dedupe record
      handler - the handler to guard
      Returns:
      the wrapped handler