Bird
Raised Fist0

Given a Kafka producer with transactions enabled, what happens if producer.commitTransaction() is not called after producer.beginTransaction()?

medium📝 Predict Output Q4 of Q15
Kafka - Message Delivery Semantics
Given a Kafka producer with transactions enabled, what happens if producer.commitTransaction() is not called after producer.beginTransaction()?
AMessages are immediately visible to consumers without transaction commit
BThe transaction remains open and messages are not visible to consumers
CProducer throws a syntax error and stops
DMessages are lost and never stored in Kafka
Step-by-Step Solution
Solution:
  1. Step 1: Understand transaction lifecycle in Kafka producer

    After beginTransaction(), messages are buffered and not visible until commitTransaction() is called.
  2. Step 2: Consequence of missing commitTransaction()

    Without commit, the transaction stays open and messages remain invisible to consumers.
  3. Final Answer:

    The transaction remains open and messages are not visible to consumers -> Option B
  4. Quick Check:

    Missing commitTransaction = messages hidden [OK]
Quick Trick: Always call commitTransaction to publish messages [OK]
Common Mistakes:
MISTAKES
  • Assuming messages are visible without commit
  • Expecting syntax error without commit
  • Thinking messages get lost automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes