Compare at-least-once processing with Kafka exactly-once processing guarantees.

Instruction: Use a crash-and-retry example to explain duplicates, offset commits, transactional Kafka outputs and the limits for external side effects.

Context: Assess failure semantics and the scope of Kafka transactions without equating exactly-once results with application code executing only once.

Updated

Official answer

At-least-once processing allows a record to be processed again after a failure. For example, an application writes its result and then commits the input offset. If it crashes after the write but before the commit, the next owner replays that input. The external write therefore needs an idempotency or duplicate-handling strategy.

At-most-once behavior can result from committing progress before performing the work: a crash in between can skip that work permanently. Neither phrase removes assumptions about source retention, retries and the durability of the receiving system.

Kafka's exactly-once processing support can atomically commit Kafka output records with consumed offsets. On failure, an aborted transaction does not advance those offsets, and read_committed consumers do not see its aborted output. A retry can execute the application code again, while only the committed result becomes visible. Kafka Streams provides this within its documented configured processing boundary.

An idempotent producer alone handles its retry duplicates; it does not combine arbitrary consumer progress and external side effects into one transaction. Kafka transactions also do not make an HTTP payment or an unrelated database write exactly once. Those effects need a compatible atomic integration, a stable business idempotency key or reconciliation.

Choose semantics from the business failure cases, not the label. Test a crash before the result, after the result but before committing progress, and during an uncertain commit. Compare throughput and latency only after the correctness requirement is fixed.

Consumer commit behavior, transactions, Streams configuration

Related Questions