Skip to content
hashkey.bond

Archivedistributed-systems

Exactly-Once Delivery Is a Transaction, Not a Transport

Queues promise it, but the guarantee always comes from deduplication and atomic state changes downstream.

Published
Reading time
1 min read

No network protocol delivers exactly once. What systems actually provide is at-least-once delivery plus idempotent consumption, or a transactional handoff where the offset commit and the effect are atomic.

Three real patterns

  1. Idempotent consumer: each message carries a unique ID; the consumer records processed IDs in the same transaction as its side effect.
  2. Transactional outbox: the producer writes the message to a table in the same transaction as the state change, and a relay publishes it.
  3. Two-phase commit with the broker: the consumer and broker coordinate a transaction (Kafka transactions, exactly-once semantics in stream processors).

The fine print

  • Kafka's exactly-once is scoped to Kafka reads/writes and transactional producers; external side effects still need idempotency.
  • Dedup tables need retention policies and a unique constraint that is actually enforced.
  • "Effectively once" is the honest term.

Takeaway: ask where the duplicate would be detected and which transaction makes detection atomic. If there is no such place, you have at-least-once.