Bird
0
0

Identify the error in this Kafka consumer configuration snippet:

medium📝 Debug Q14 of 15
Kafka - Consumers

Identify the error in this Kafka consumer configuration snippet:

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "test-group");
props.put("enable.auto.commit", true);
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
A"enable.auto.commit" should be a String "true", not boolean true
B"group.id" is missing and must be added
C"bootstrap.servers" value is incorrect format
DDeserializers should be set to IntegerDeserializer
Step-by-Step Solution
Solution:
  1. Step 1: Check data types for properties

    Kafka consumer properties expect String values, so "enable.auto.commit" should be set as "true" (a String), not boolean true.
  2. Step 2: Verify other properties

    "group.id" is present, "bootstrap.servers" format is correct, and deserializers are valid for String keys and values.
  3. Final Answer:

    "enable.auto.commit" should be a String "true", not boolean true -> Option A
  4. Quick Check:

    Properties values must be Strings [OK]
Quick Trick: Property values must be strings, not booleans [OK]
Common Mistakes:
  • Using boolean true instead of "true" string
  • Omitting group.id property
  • Incorrect bootstrap.servers format
  • Wrong deserializer class for String data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes