Bird
Raised Fist0

How should you correctly configure a Kafka producer in Java to enable idempotence?

easy📝 Syntax Q3 of Q15
Kafka - Message Delivery Semantics

How should you correctly configure a Kafka producer in Java to enable idempotence?

Properties props = new Properties();
// Which line enables idempotence?
Aprops.put("enableIdempotence", "yes");
Bprops.put("idempotence.enabled", true);
Cprops.put("enable.idempotence", "true");
Dprops.put("enable.idempotence", true);
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct property key

    The correct Kafka producer config key is enable.idempotence.
  2. Step 2: Correct value type

    Values must be strings in Java Properties, so "true" as a string is correct.
  3. Step 3: Evaluate options

    props.put("enable.idempotence", "true"); uses correct key and string value. props.put("enable.idempotence", true); uses boolean true which is invalid in Properties.
  4. Final Answer:

    props.put("enable.idempotence", "true"); -> Option C
  5. Quick Check:

    Property keys and string values required [OK]
Quick Trick: Use string "true" with key enable.idempotence [OK]
Common Mistakes:
MISTAKES
  • Using boolean true instead of string "true"
  • Incorrect property key names
  • Using non-string values in Properties

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes