What is delivery guarantee in Kafka?
sobes.tech AI
Answer from AI
Delivery guarantees in Kafka describe how messages are delivered from the producer to the broker and from the broker to the consumer. The main levels of guarantees:
-
At most once — a message may be lost but will not be duplicated. Used when speed is important and data loss is acceptable.
-
At least once — a message is guaranteed to be delivered but may be duplicated. This is the standard mode of Kafka operation.
-
Exactly once — a message is delivered and processed exactly once, without duplicates. Achieved in Kafka using idempotent producers and transactions.
To implement exactly once in Kafka Go clients, support for idempotence and transactions should be used if the library allows.
Example of configuring a producer with idempotence (pseudocode):
producer, _ := kafka.NewProducer(&kafka.ConfigMap{
"bootstrap.servers": "localhost",
"enable.idempotence": true, // guarantees exactly-once
})