# Exactly-Once Semantics

> Each message counts one time, even if it is sent twice.

**Field:** Data Engineering  
**Category:** Ingestion & Streaming  
**Also known as:** Exactly Once, Exactly-Once Delivery, Exactly-Once Processing, EOS

## Think of it like

It is like a teacher who ticks your name when you hand in work. Hand it in twice, and it still counts once.

## Definition

Exactly-once semantics means each message changes the result one time only, even when sends are retried. The message may still travel twice, but the copy has no effect. Each message gets an ID. The result and the read position are saved together. Kafka offers it through safe producers and transactions. It is slower and harder to set up than the other two.

## Example

A bank adds up deposits from a stream. With exactly-once turned on, a retried deposit is never added to the total twice.

## Why it matters

Money, stock counts and billing cannot be off by one. Exactly-once makes streaming safe for them.

## Common mistake

Thinking it covers the whole path. It stops at the edge, so a write to an outside system still needs its own check.

## Three principles

- **Counted once.** The effect happens one time.
- **IDs and transactions.** Copies are spotted and dropped.
- **Ends at the edge.** Outside writes need their own care.

## Related terms

- [At-Least-Once Delivery](https://learn.benibix.com/term/data/at-least-once-delivery)
- [At-Most-Once Delivery](https://learn.benibix.com/term/data/at-most-once-delivery)
- [Apache Kafka](https://learn.benibix.com/term/data/apache-kafka)
- [Idempotency](https://learn.benibix.com/term/development/idempotency)
- [Database Transaction](https://learn.benibix.com/term/development/transaction)

## Told apart from

- [At-Least-Once vs Exactly-Once](https://learn.benibix.com/compare/at-least-once-vs-exactly-once): People think exactly-once means each message travels only once. It does not. Under at-least-once, a message that is sent again is counted again. Under exactly-once, it may still be sent twice, but the copy is spotted by its ID and has no effect.

![Three rows, one per guarantee. At most once: a message is lost and never sent again. At least once: a message is sent again after no reply and arrives twice. Exactly once: a resend arrives but the second copy is dropped, so the result counts it once.](https://learn.benibix.com/diagrams/delivery-guarantees.svg)

---

Source: https://learn.benibix.com/term/data/exactly-once-semantics
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
