intermediatePersistence Layer
Why does a Kafka consumer that writes to a database need to think about idempotency, not just 'save the record'?
Kafka's at-least-once delivery (the default, safest guarantee without extra work) means the SAME message can be delivered and processed more than once, e.g. after a consumer restart before it committed its offset. Without an idempotency check (like a unique constraint on an event ID, or an upsert instead of a blind insert), a redelivered message can create duplicate rows or double-apply an effect.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
Why does a Kafka consumer that writes to a database need to think about idempotency, not just 'save the record'?