Imagine a payment service that consumes a charge-customer topic. With at-least-once, a broker that does not receive an ack will redeliver the charge, and a naive consumer charges the card twice.
The idempotent fix: each charge message carries a unique payment_id. Before calling the card processor, the consumer inserts that payment_id into a payments table with a UNIQUE constraint. If the insert fails because the id already exists, the consumer knows it already handled this message and skips the charge entirely. The card is never charged twice. One gap remains: if the consumer crashes after the insert but before the charge, the redelivered message is skipped and the charge never happens, so real systems also pass payment_id to the card processor as an idempotency key.
The transactional fix in Kafka Streams: read the charge, write the result to an output topic, and commit the source offset, all inside one transaction with processing.guarantee set to exactly_once_v2. If the consumer crashes mid-flight the transaction aborts, the offset is not advanced, and the whole step replays cleanly with no partial effect.