Skip to main content

Message Delivery Semantics

1. Executive Summary​

Message delivery semantics describe what guarantees a messaging system provides when a producer sends a message and a consumer processes it. The three classical labels—at-most-once, at-least-once, and exactly-once—are often misunderstood because they apply at different layers (broker acknowledgment, consumer offset commit, end-to-end business effect) and because exactly-once delivery is impossible in the general asynchronous network model without cooperation from producers, brokers, and consumers.

In practice, production systems overwhelmingly implement at-least-once transport with idempotent or deduplicated consumers to achieve effectively-once processing. Architects must separate safety (no duplicate side effects) from liveness (messages eventually processed) and from ordering (per-partition or causal), because strengthening one dimension often weakens another.

This chapter covers formal semantics, acknowledgment protocols, offset management, transactional messaging, duplicate detection, failure scenarios, performance tradeoffs, and principal-level interview framing for designing reliable event-driven systems.

2. Why This Topic Matters​

Principal interviews frequently ask: "How do you guarantee a payment event is processed exactly once?" Weak answers claim "Kafka exactly-once" or "use a queue with deduplication" without defining the scope.

Strong candidates explain:

  • At-least-once is the default for durable messaging; duplicates are expected, not exceptional.
  • Exactly-once at the broker layer (e.g., idempotent producer + transactional writes) does not automatically mean exactly-once business outcomes without idempotent handlers.
  • At-most-once sacrifices data for simplicity—acceptable only when loss is tolerable (metrics, sampling).
  • Ordering and delivery guarantees are orthogonal concerns.

Production incidents include double charges, duplicate inventory reservations, poison messages retried forever, and offset commits before processing causing silent loss. Architects who conflate broker guarantees with application correctness build systems that fail under retries, consumer restarts, and network partitions.

3. Problems Being Solved​

ProblemNaive approachMessaging semantics approach
Lost messagesFire-and-forget UDP-styleAcknowledgments + durable log
Duplicate processingHope retries don't happenIdempotency keys + dedup store
Partial failureRetry blindlyAt-least-once + compensating logic
Ordering violationsSingle global queuePartition keys + sequence numbers
Crash between process and ackUndefined behaviorTransactional outbox or offset-after-process

Messaging semantics solve reliable asynchronous communication across process and network failures. They do not solve distributed transactions without additional patterns (sagas, outbox, 2PC), Byzantine adversaries, or automatic business-level deduplication without application design.

4. Assumptions and System Model​

Assume an asynchronous network with partial failure:

  • Producers, brokers, and consumers are separate processes that can crash independently.
  • Messages may be delayed, duplicated, or reordered across partitions unless the broker provides stronger guarantees.
  • Not Byzantine unless discussing signed messages separately.
  • Consumers may crash after processing but before acknowledging (duplicate) or crash after ack but before processing (loss with wrong ack ordering).

Layers of semantics:

LayerQuestion answered
Producer → brokerDid the broker durably accept the message?
Broker → consumerWill the consumer see the message at least once?
Consumer → side effectWill the business operation happen exactly once?

End-to-end exactly-once requires alignment across all three layers plus idempotent or transactional application logic.

5. Essential Terminology​

TermDefinition
At-most-onceMessage delivered zero or one time; loss possible, no duplicates from retry.
At-least-onceMessage delivered one or more times until acknowledged; duplicates possible.
Exactly-onceEach message causes exactly one observable effect—often end-to-end claim.
Acknowledgment (ack)Consumer or broker confirmation of receipt or processing.
OffsetPosition in a partition log; consumer commits offset after processing.
Idempotent consumerProcessing same message twice yields same state as once.
DeduplicationStore of seen message IDs to reject duplicates.
Poison messageMessage that always fails processing; blocks or loops retries.
Dead-letter queue (DLQ)Destination for messages that exceed retry limits.
Effectively-onceAt-least-once transport + idempotent handler = one business effect.

Mnemonic: At-least-once arrives; idempotency makes it once.

6. Core Mechanism​

At-least-once with manual acknowledgment​

Figure 1: At-least-once path—offset committed only after successful side effect; crash before ack causes redelivery.

Three semantic models compared​

Figure 2: At-most-once may lose; at-least-once may duplicate; effectively-once combines durable delivery with idempotent processing.

Offset commit ordering trap​

Figure 3: Committing offset before processing creates at-most-once behavior despite at-least-once broker.

7. Step-by-Step Walkthrough​

Scenario: Order service publishes OrderCreated events; payment service consumes and charges customer.

StepActionSemantics implication
1Producer sends event with order_id as keyPartition ordering per order
2Broker replicates to ISR, acks producerAt-least-once if producer retries on timeout
3Consumer polls messageDelivery to consumer process
4Consumer checks idempotency table for event_idDedup before side effect
5Consumer calls payment API with idempotency keyExternal system dedup
6Consumer inserts event_id in local tx with business updateAtomic dedup + effect
7Consumer commits Kafka offsetAt-least-once preserved

Failure at step 6 after payment but before DB commit:

  • Redelivery occurs; idempotency key prevents double charge.
  • Safety preserved; liveness requires consumer to eventually succeed or route to DLQ.

Failure at step 7 after DB commit but before offset:

  • Redelivery; idempotency table hit—no duplicate charge.
  • Effectively-once achieved.

Auto-commit anti-pattern:

SettingBehaviorRisk
enable.auto.commit=true before processOffset may advance on pollLost messages on crash
Manual commit after processRedelivery on crashDuplicates—need idempotency
Transactional consume-process-produceAtomic offset + outputHigher latency, broker support required

End-to-end semantics decision matrix:

Business domainRecommended transportEffect boundaryReconciliation
Payment captureAt-least-once + idempotent APIPayment provider + ledger DBNightly gateway match
Inventory reservationAt-least-once + conditional DB updateWHERE stock >= qtyStock count audit
Email notificationAt-least-once (duplicate email acceptable) or at-most-onceEmail provider dedup if availableLow priority
Metrics / telemetryAt-most-once or samplingDashboard aggregatesStatistical tolerance
Audit log appendAt-least-once + unique event_idAppend-only audit tableImmutable log review

Comparing broker "exactly-once" to application guarantees:

Kafka's transactional API provides read_committed isolation for consumers within a transaction—messages from aborted transactions are not visible. This is a broker safety property: it prevents duplicate published messages from failed transactions from appearing downstream. It does not prevent a consumer from:

  1. Processing a message and crashing before committing the transaction offset.
  2. Successfully calling an external HTTP API twice on redelivery.
  3. Writing to two external systems where only one succeeds.

Principal architects document a semantics matrix per pipeline stage so teams do not assume one checkbox solves the entire flow.

Idempotency implementation patterns (detailed):

PatternMechanismProsCons
Natural idempotencySET balance = 100 (absolute)No extra storeRare in event-driven updates
Idempotency key tableINSERT event_id with unique constraintSimple, auditableStorage growth; needs TTL
Conditional updateUPDATE ... WHERE version = NOptimistic concurrencyConflicts on hot keys
Outbox + single consumerSerialized processing per aggregateStrong per-entity orderingThroughput limit per key
Bloom filter pre-checkProbabilistic duplicate detectionMemory efficientFalse positives need handling

Consumer offset storage co-location:

The strongest pattern stores the processed offset (or event_id) in the same database transaction as the business write:

BEGIN;
INSERT INTO invoices (...) VALUES (...);
INSERT INTO processed_events (event_id) VALUES ('evt-123');
COMMIT;
-- then commit Kafka offset

If the process crashes after DB commit but before offset commit, redelivery occurs; the unique constraint on event_id makes the retry a no-op. This is the practical foundation of effectively-once in microservices without distributed transactions across Kafka and PostgreSQL.

8. Invariants and Guarantees​

PropertyTypeStatement
No duplicate side effectsSafety (application)Requires idempotency or dedup—not broker default
No message lossSafetyRequires at-least-once + correct ack ordering
Eventual deliveryLivenessConsumer must progress; poison messages threaten
Per-partition orderingSafety (ordering)Single consumer per partition preserves order
Global exactly-once deliveryImpossible (general async model)Without shared transactional boundary

Formal distinction: Broker exactly-once semantics (Kafka transactions) provide atomic write of messages to multiple partitions and read-process-write within a transaction scope—they do not replace application idempotency for external systems (payment gateways, email APIs).

9. Failure Scenarios​

Scenario 1: Producer retry after successful write​

Setup: Producer times out waiting for ack; broker actually stored message; producer retries.

Effect: Duplicate messages in log—distinct offsets, same payload.

Mitigation: Idempotent producer (PID + sequence); dedup on business_id; compacted topics with key-based dedup.

Scenario 2: Consumer crash after processing​

Setup: Payment charged; offset not committed; consumer restarts.

Effect: Redelivery—duplicate unless idempotent.

Mitigation: Idempotency keys; store processed offsets in same DB transaction as side effect.

Scenario 3: Consumer crash after offset, before processing​

Setup: Auto-commit enabled; crash before handler runs.

Effect: Message lost—at-most-once.

Mitigation: Disable auto-commit; commit only after success.

Scenario 4: Poison message​

Setup: Malformed payload causes infinite exceptions.

Effect: Consumer stuck; partition lag grows; no liveness.

Mitigation: Retry budget; DLQ; schema validation at produce time.

Scenario 5: Rebalance during processing​

Setup: Consumer group rebalance assigns partition mid-batch.

Effect: Duplicate processing if offset committed for whole batch but only partial process.

Mitigation: Cooperative sticky assignors; process-then-commit per message; transactional processing.

Scenario 6: Split brain consumer​

Setup: Two consumers believe they own same partition (misconfiguration or long GC pause).

Effect: Parallel duplicate processing.

Mitigation: Single active consumer pattern; fencing; short session timeouts with careful tuning.

10. Performance Characteristics​

FactorImpact
Synchronous replicationHigher durability latency before producer ack
Manual ack per messageLower throughput than batch commit
Idempotency store lookupExtra read per message—cache hot keys
Transactional messaging~20–30% throughput reduction (implementation-dependent; verify per broker version)
DLQ routingSmall overhead; prevents catastrophic retry storms

Compared to synchronous RPC: Messaging decouples latency but introduces eventual processing and duplicate handling complexity. Batch consumers achieve higher throughput by amortizing ack cost.

11. Scalability Limits​

  • Dedup store growth—TTL or compaction required for unbounded event_id sets.
  • Per-partition ordering caps parallel consumers per key to one.
  • Transactional coordinator becomes bottleneck at extreme produce rates.
  • DLQ volume during bad deploys can overwhelm ops—rate-limit poison routing.

12. Operational Considerations​

  • Consumer lag alerts per partition—not just aggregate.
  • DLQ replay tooling with idempotency preserved.
  • Schema registry enforcement prevents poison payloads.
  • Runbooks for "lag spiking" vs "duplicates detected in reconciliation."
  • Dashboards: produce rate, consume rate, retry count, DLQ depth.
  • Chaos tests: kill consumer mid-batch; verify no loss and bounded duplicates.

13. Security Considerations​

  • Message tampering: TLS in transit; optional signing for high-trust domains.
  • Replay attacks: Idempotency keys bound to tenant and time window.
  • ACLs: Producers and consumers least-privilege per topic.
  • PII in messages: Encryption at rest; minimize payload sensitivity.

14. Cost Considerations​

  • At-least-once with dedup: Extra storage (dedup table) and read amplification.
  • Exactly-once broker features: Higher broker CPU and latency.
  • DLQ storage and replay labor: Operational cost during incidents.
  • Saved cost: Avoids custom lossy pipelines that require manual data repair.

15. Production Implementations​

Apache Kafka​

  • At-least-once: Default with acks=all and consumer manual commit.
  • Idempotent producer: enable.idempotence=true deduplicates producer retries within session.
  • Transactions: Atomic multi-partition produce and consume-transform-produce within transactional.id.

Amazon SQS​

  • At-least-once standard queues; at-most-once FIFO with deduplication ID (within 5-minute window—verify current AWS docs).
  • Visibility timeout drives redelivery semantics.

RabbitMQ​

  • Ack/nack manual mode for at-least-once; publisher confirms for durable publish.
  • No native exactly-once—application dedup required.

Google Pub/Sub​

  • At-least-once delivery; acknowledgment deadline extensions.
  • Ordering keys provide per-key sequence.

Pulsar​

  • Acknowledgment types: individual, cumulative, negative ack with redelivery.
  • Transaction API for end-to-end atomicity within Pulsar scope.

Implementation note: Vendor "exactly-once" marketing often means broker-internal guarantees—always map to your business effect boundary.

16. Alternatives and Tradeoffs​

ApproachDuplicatesLoss riskComplexity
At-most-onceNoneHighLow
At-least-once + idempotencyTransport duplicatesLowMedium
Broker transactionsReduced in logLowHigh
Outbox + CDCControlled emissionLowMedium
Synchronous RPC + DBNone in message layerCoupled failureMedium

17. Common Misconceptions​

MisconceptionReality
"Exactly-once Kafka = no duplicate charges"External APIs need idempotency keys.
"Auto-commit is fine for payments"Creates at-most-once loss window.
"FIFO = exactly-once"FIFO orders; duplicates still possible on retry.
"Dedup table optional for idempotent APIs"APIs may not be idempotent; local dedup still needed.
"More retries = safer"Retries amplify duplicates and load without idempotency.

18. Principal Architect Perspective​

  1. Define the effect boundary—database row, payment API, or email send—before choosing semantics.
  2. Standardize idempotency keys across all event consumers; reject messages without them on critical paths.
  3. Never auto-commit offsets on financial or inventory topics.
  4. Pair messaging with reconciliation—nightly compare ledger to events.
  5. Document semantic contract per topic: ordering, retention, delivery, schema version.

Governance: Publish a messaging contract template (delivery, ordering, schema, DLQ policy) for every new topic. Teams that skip this recreate the same offset and dedup bugs in every microservice.

19. Architecture Review Exercise​

Scenario: Team uses Kafka with enable.auto.commit=true, processes payments in consumer, no idempotency keys.

Review prompts:

  1. What happens on consumer crash after charge?
  2. What happens on consumer crash after poll, before charge?
  3. How would reconciliation detect issues?
  4. Redesign for effectively-once?

Expected findings: Disable auto-commit; idempotency key per order_id; dedup table; DLQ; payment provider idempotency; lag and duplicate-rate metrics.

20. Whiteboard Explanation​

90-second version:

"Message delivery semantics describe whether messages can be lost, duplicated, or processed once. Pure exactly-once end-to-end is impossible over an async network without cooperation—you get at-least-once from durable brokers with acknowledgments. Duplicates happen when producers retry, consumers crash before acking, or rebalances occur. The production pattern is at-least-once transport plus idempotent consumers: store processed message IDs or use business idempotency keys in the same database transaction as your side effect. Commit offsets only after successful processing—auto-commit before process creates silent loss. Broker transactions like Kafka exactly-once shrink the duplicate window inside the broker but don't fix external API calls. Define your effect boundary, design for duplicates, and reconcile money paths."

21. Interview Questions​

  1. Define at-least-once vs at-most-once.

    • Signals: Duplicates vs loss; ack timing.
  2. Is exactly-once possible end-to-end?

    • Signals: Impossible in general; effectively-once with idempotency.
  3. When commit Kafka offset?

    • Signals: After process; same tx as side effect ideally.
  4. What does Kafka idempotent producer do?

    • Signals: Dedupes producer retries via PID/sequence—not consumer dedup.
  5. Auto-commit risks?

    • Signals: At-most-once loss.
  6. Poison message handling?

    • Signals: Retry limit, DLQ, alert.
  7. Ordering vs delivery semantics?

    • Signals: Orthogonal; partition key ordering.
  8. Design payment consumer semantics.

    • Signals: Idempotency key, dedup, manual ack, reconciliation.
  9. DLQ replay safety?

    • Signals: Idempotency must hold on replay.
  10. Transactional outbox relation?

    • Signals: Reliable publish aligned with DB commit.

Scoring rubric:

DimensionStrongWeak
Layer clarityProducer/broker/consumer/effect"Kafka EOS" hand-wave
Failure casesCrash before/after ackIgnores retries
MitigationIdempotency + offset order"Use exactly-once"

22. Interview Follow-Ups​

  1. Duplicate charges reported—debug?

    • Signals: Idempotency audit, offset commit order, producer retries, rebalance logs.
  2. At-most-once acceptable when?

    • Signals: Metrics, logs, non-critical telemetry.
  3. How dedup store scale?

    • Signals: TTL, partition by key, compacted topic of processed IDs.

22A. Production Low-Level Design (Interview + Game Day)​

Achieve effectively-once billing effects under at-least-once delivery. Production LLD and Game Day Standard.

Semantics → mechanism​

ClaimMechanism
At-most-onceNo retry / lose on fail
At-least-onceRetry + durable
Effectively-onceAt-least-once + idempotent consumer / inbox
Broker EOSHelps produce/consume chain; not external side effects

Step-by-step flow:

StepSafety
1Expect redelivery
2–4Dedup before side effect
5Replay safe

22B. Game Day Playbooks​

#DrillInjectDetectMitigateVerify
GD-1RedeliveryReset offsets / redriveDuplicate attempts metricInbox hitSingle bill
GD-2Crash after bill before offsetKill consumer mid-handlerStuck / retryInbox completedNo double bill
GD-3"Enable EOS" misconceptionKafka TX only, no inboxDouble side effectAdd inboxEffectively-once

GD-1 — Redelivery storm​

23. Strong Answer Example​

Question: "Guarantee order events processed exactly once for billing."

Answer this as a 45-minute design discussion using the PRACTICE framework. Below is how a strong student sounds aloud—effectively-once, not "turn on Kafka EOS."

PRACTICE interview answer map for exactly-once billing of order events

Figure A: PRACTICE map — Problem → Requirements → Assumptions → Capacity → Topology → Invariants → Constraints → Evolution.


Student interview script (PRACTICE)​

P — Problem framing​

"True end-to-end exactly-once delivery over an async network isn't something you 'turn on.' Producers retry, consumers crash before ack, rebalances redeliver—so transport is almost always at-least-once.

For billing, the safety property we care about is: one business effect per order event—one invoice / one charge—not zero (lost revenue) and not two (double bill).

Production pattern: at-least-once Kafka + idempotent billing handler (inbox / unique event_id) + PSP idempotency key + offset commit after the local side effect. That is effectively-once.

Short answer: Scope the guarantee at the billing DB + payment provider. Broker EOS alone does not protect external charge APIs."

R — Requirements​

RequirementDesign
No double invoice / double chargeUnique event_id (and/or order_id) in billing DB
No silent skip of paid ordersAt-least-once + don't commit offset before process
Safe retries / rebalancesIdempotent handler + PSP key
Per-order orderingKafka key = order_id
Ops / auditReconcile billing ledger ↔ PSP ↔ orders

"I'd clarify: authorize vs capture? Refunds? Partial charges? Multi-tenant?"

A — Assumptions (state aloud)​

AssumptionWhy it matters
Kafka (or similar) busAt-least-once with manual commits
Order side uses outboxNo dual-write lost OrderCreated
Billing has its own DBLocal TX for inbox + invoice
External PSPNeeds its own idempotency key
Crashes & duplicates happenDesign for them, don't deny them

"I'd say: Kafka EOS / idempotent producer shrinks broker duplicates—it does not make Stripe calls exactly-once."

C — Capacity​

Dedupe / inbox table → unique index on event_id; prune by retention
Billing consumer parallelism → by order_id partitions; watch hot keys
PSP latency → timeouts; don't hold offset forever without care
Reconciliation → cheap daily job; high signal on money drift
Auto-commit → forbidden on billing path (creates loss window)

"I'd rather pay for a dedupe store and reconcile than 'optimize' with auto-commit."

T — Topology (draw this)​

Effectively-once billing pipeline

Figure B: Outbox → Kafka → billing consumer → inbox + invoice in one local TX → PSP with idempotency key.

Delivery semantics vs billing safety

Figure C: At-most-once can lose charges; at-least-once can double-bill; effectively-once = ALO + idempotent side effects + reconcile.

LayerWhat we configure
ProduceOutbox; acks=all; key=order_id; optional idempotent producer
ConsumeManual commit after process; no auto-commit
Local effectINSERT processed_events(event_id) UNIQUE + create invoice same TX
External effectPSP idempotency key (order_id / payment intent)
PoisonN retries → DLQ + alert; don't block partition forever
AuditNightly ledger ↔ gateway ↔ order service

I — Invariants (safety)​

"I'd write on the whiteboard:

  1. Effect boundary = billing invoice row + PSP charge—not 'Kafka message once.'
  2. At-least-once transport; no duplicate side effects via inbox uniqueness.
  3. Offset commit after successful local TX (and after PSP success, or store 'pending capture' carefully).
  4. PSP calls are independently idempotent.
  5. Broker EOS ≠ billing EOS.
  6. Reconciliation is part of the design, not optional ops fluff."

C — Constraints (second C)​

ConstraintDesign response
Crash after PSP charge, before DB commitPSP key prevents double charge; retry completes DB
Crash after DB, before offset commitRedelivery; inbox unique → no-op
Commit offset before processForbidden—that's at-most-once loss
Reorder across partitionsPartition by order_id; don't assume global order
Poison / bad schemaDLQ; versioned events; don't infinite-retry money path blindly
Multi-instance consumersUnique constraint is the fence; optional fencing tokens

E — Evolution (prove it)​

Phased delivery:

PhaseDeliverable
M1Define effect boundary + ADR: effectively-once
M2Order outbox → Kafka; billing inbox unique + invoice TX
M3PSP idempotency keys; manual offset commit
M4DLQ + alerts; lag + duplicate-skip metrics
M5Chaos: kill consumer mid-charge; replay same event
M6Nightly reconcile + support tools for mismatches

Failure modes:

FailureMitigation
"Enable Kafka exactly-once" onlyAdd inbox + PSP keys
Auto-commitDisable on billing
Double invoiceUnique on event_id / order_id
Lost chargeALO + don't ack before success
Silent driftReconciliation alerts

Observability: consumer lag, duplicate skip rate, DLQ depth, charge success/fail, reconcile delta amount/count.


Closing line (interview)​

"So: I don't promise pure exactly-once delivery—I deliver effectively-once billing. Kafka is at-least-once with manual commits after a local transaction that records event_id in an inbox and creates the invoice under a unique constraint. The payment provider gets the same idempotency key. Poison goes to a DLQ, and we reconcile nightly. Broker exactly-once alone is not enough for external charges."

Scoring signals​

StrongWeak / red flag
Effectively-once + effect boundary"Turn on Kafka exactly-once"
Inbox unique + offset-after-processAuto-commit / ack-before-work
PSP idempotency keyIgnores external API
Outbox on produce sideDual-write shrug
DLQ + reconcileNo ops/money follow-through
Separates broker vs business EOSConflates layers

Compact outline (if time-boxed to 2 minutes)​

"Effectively-once, not broker magic. At-least-once Kafka; manual commit after local TX that inserts unique event_id + invoice. PSP idempotency key. DLQ for poison. Reconcile. Don't auto-commit; don't trust Kafka EOS alone for charges."

24. Weak Answer Example​

Question: "Guarantee order events processed exactly once for billing."

"Turn on Kafka exactly-once and use a consumer group."

Why weak / red flags: No effect boundary, no application idempotency, no offset-after-process discipline, no external PSP handling—conflates broker marketing with billing safety.

25. Hands-On Exercise​

Pair with Lab 006: Kafka Stream Processing — produce orders, run enricher twice to see idempotent dedup, inject poison → DLT.

Pair with Lab 009: Transactional Outbox — run POST /v1/consumer/run twice to see at-least-once delivery + idempotent dedup (duplicates: 1 on second run).

  1. Run Kafka locally; produce 100 messages with a duplicate injection script.
  2. Consumer with auto-commit—measure loss on kill -9 mid-process.
  3. Add manual commit after process; observe duplicates on kill.
  4. Add SQLite dedup table in same logical unit as handler.
  5. Plot duplicate rate vs retry policy.
  6. Route failing messages to DLQ topic.
  7. Document semantic contract for your topic.

26. Knowledge Check​

  1. At-least-once may produce? (Duplicates.)
  2. Auto-commit before process risks? (Message loss.)
  3. Effectively-once requires? (At-least-once + idempotent handler.)
  4. Idempotent producer dedupes? (Producer retries within session—not all duplicates.)
  5. Poison message destination? (DLQ after retry budget.)

27. Flashcards​

#FrontBack
1At-most-onceZero or one delivery; loss OK.
2At-least-onceOne or more until acked.
3Effectively-onceAt-least-once + idempotency.
4Offset commit timingAfter process for safety.
5Idempotent producerKafka PID/sequence dedup.
6DLQFailed messages after retries.
7Poison messageAlways fails processing.
8OrderingPer-partition with single consumer.
9Auto-commit trapLossy at-most-once behavior.
10Effect boundaryDB vs API vs broker scope.

28. Cheat Sheet​

SEMANTICS
At-most-once: may LOSE
At-least-once: may DUPLICATE
Exactly-once: impossible E2E generally
Effectively-once: ALO + idempotent consumer

OFFSET RULE
Process → then commit offset
Never auto-commit before side effect

DEDUP
event_id unique constraint
Business idempotency key for APIs
TTL on dedup store

OPS
Lag per partition
DLQ depth
Reconciliation for money

30. References​

Primary sources​

  • Chandy, K. M., & Lamport, L. (1985). "Distributed Snapshots: Determining Global States of Distributed Systems." ACM TOCS — foundational distributed state reasoning.
  • Kleppmann, M. (2017). Designing Data-Intensive Applications — Ch. 11 stream processing delivery semantics.

Official documentation​

Distinction​

Claim typeSource
Impossibility of pure EOS over async networkDistributed systems theory; DDIA
Kafka idempotent producer behaviorApache Kafka documentation
Effectively-once patternEngineering practice; Kleppmann