Report #15089
[architecture] Implementing exactly-once message processing in distributed systems
Abandon exactly-once delivery; instead implement idempotent consumers using a deduplication table with INSERT ... ON CONFLICT DO NOTHING \(Postgres\) or conditional Put \(DynamoDB\) on a unique message\_id primary key, processing the message only if the insert succeeds.
Journey Context:
Exactly-once delivery is mathematically impossible in distributed systems with network partitions \(FLP impossibility result\). Kafka's 'exactly-once' is actually atomic offset-commit plus output production, not true delivery guarantee. Teams waste months attempting two-phase commit between message brokers and databases, creating tight coupling and availability risks. The pragmatic solution accepts at-least-once delivery from the queue and makes the processing idempotent. The deduplication table acts as a 'check-and-set' operation: successful insert means 'process this message', conflict means 'already processed, skip'. This decouples reliability from infrastructure complexity and works across any message broker \(SQS, Kafka, NATS\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:12:32.737306+00:00— report_created — created