Commit after, not before
Commit after the side effect
Offsets are the consumer's bookmark. Two anti-patterns kill EOS:
enable.auto.commit=true— offsets advance every 5s in the background, before your handler returns. A crash mid-handle replays nothing and you lose data.- Committing before writing downstream — guarantees duplicates on retry.
Rule: enable.auto.commit=false, then commitSync() (or transactional sendOffsetsToTransaction) after the side-effect succeeds.