intermediatePersistence Layer

Why might a consumer intentionally write to a local database inside the SAME transaction as committing its Kafka offset?

Committing the Kafka offset and writing to the database are two separate systems — if the DB write succeeds but the app crashes before committing the offset, the message gets reprocessed (safe if idempotent); but if you want to avoid ANY duplicate processing risk, the 'offset commit as part of the DB transaction' pattern (rare, needs manual offset storage in the DB itself) ties both operations to one atomic outcome.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why is `@EmbeddedKafka` valuable for testing a Kafka consumer's rebalancing or retry behavior specifically?← Back to all Kafka & Microservices questions