Kafka: How to handle duplicate messages
Kafka is "at least once" by default. ???? What is "At Least Once" in Kafka? (Simple Explanation) "At least once" means: Kafka guarantees that every message will be delivered , But sometimes the same message might be delivered more than once (duplicate). 🔁 Why it happens: If a consumer crashes or times out, Kafka resends the message after retry. (Here, what I meant by resend that Kafka allows to pull the same message. If you know about Kafka Architecture it does not push/ send messages to consumer. Instead consumer is the one pulls the messages) If the system didn’t record that it already processed it, it may process it again . 🛠 Example: You (Consumer) receive a payment event. You process it and update the database. But before you commit (Telling Kafka "I have successfully processed this message" or in other words consumer failed to submit the offset to Kafka ), the consumer crashes. Kafka thinks it fa...