Last Updated: January 9, 2026
When you send a message through a messaging system, what guarantees do you have about its delivery? Will it definitely arrive? Could it arrive more than once?
These questions are at the heart of delivery semantics. Delivery semantics define the contract between a messaging system and its users about how many times a message will be delivered.
Understanding these guarantees is essential because choosing the wrong semantics can lead to lost data, duplicate processing, or systems that are unnecessarily complex.
In this chapter, you will learn:
Messaging systems offer three levels of delivery guarantees. Each makes different trade-offs between reliability, performance, and complexity.
| Semantic | Guarantee | Message Loss | Duplicates |
|---|---|---|---|
| At-most-once | Delivered 0 or 1 times | Possible | Never |
| At-least-once | Delivered 1 or more times | Never | Possible |
| Exactly-once | Delivered exactly 1 time | Never | Never |
Let us explore each in detail.
At-most-once means a message is delivered zero or one times. The system makes one attempt and does not retry if it fails. This is the simplest semantic but accepts that messages may be lost.
The broker delivers the message and immediately deletes it, regardless of whether the consumer received or processed it.
At-most-once is the simplest to implement:
At-most-once is appropriate when:
At-least-once means a message is delivered one or more times. The system keeps retrying until it receives confirmation of delivery. This ensures no messages are lost but accepts that messages may be delivered multiple times.
The broker retries until it receives acknowledgment. If the acknowledgment is lost, the broker retries, causing duplicate delivery.
Even in a perfectly implemented system, duplicates can occur because the broker cannot distinguish between:
At-least-once is appropriate when:
At-least-once delivery requires idempotent consumers. An operation is idempotent if performing it multiple times has the same effect as performing it once.
Design operations that are naturally idempotent:
Track processed message IDs:
Use unique constraints to prevent duplicates:
Exactly-once means a message is delivered exactly one time. No loss, no duplicates. This is the holy grail of messaging semantics but is harder to achieve than it sounds.
The fundamental problem is the Two Generals' Problem. Two parties communicating over an unreliable channel cannot reach certainty about shared state.
The fundamental problem: there is always a moment where the sender has committed but does not know if the receiver has received. The network can fail at any point.
When systems claim "exactly-once," they typically mean one of two things:
The infrastructure guarantees each message is delivered exactly once. This requires tight coupling between sender, broker, and receiver.
Messages may be delivered multiple times, but the effect is as if it were processed once. This is achieved through idempotency and deduplication.
Kafka achieves exactly-once semantics within its ecosystem through:
Producers assign sequence numbers. Broker deduplicates:
Atomic writes across multiple partitions:
Consumer offset commits are part of the transaction:
Exactly-once is worth the complexity when:
Delivery semantics define the guarantee about how many times a message will be delivered:
Key insight: True exactly-once delivery is impossible over unreliable networks. What we achieve is exactly-once processing through idempotent consumers. At-least-once delivery combined with idempotent consumers gives you effective exactly-once processing with less complexity than native exactly-once support.
But what happens when a message fails processing repeatedly? It cannot stay in the queue forever, blocking other messages. This is where dead letter queues come in. In the next chapter, we will explore how to handle failed messages gracefully.