Compare making a consumer idempotent with committing the result and the read position in one transaction. When would you choose each?
Sketch your own answer first, then compare it with the one below.
A strong answer
An idempotent consumer works with any at-least-once source and any target that can recognise a repeat, by key or by an operation like "set to this value". It is simple and portable. It needs a key, a store, and care about expiry.
A transactional commit saves the result and the offset together, so a failure leaves neither. It gives a clean effectively-once result without keys, but it needs a target and a source that can share a transaction or a checkpoint, which limits where it applies.
Choose idempotence for effects on external systems and for mixed technologies. Choose the transaction when the output stays inside one store you control. Either way, the guarantee ends at the system boundary.
Sources
- J. H. Saltzer, D. P. Reed, D. D. Clark (1984). End-to-end arguments in system design.
- Tyler Akidau and others (2013). MillWheel: fault-tolerant stream processing at internet scale.
- Martin Kleppmann (2017). Designing Data-Intensive Applications.