Bird
0
0

You have this Kafka consumer code connecting to Amazon MSK:

medium📝 Debug Q14 of 15
Kafka - Kubernetes and Cloud Deployment
You have this Kafka consumer code connecting to Amazon MSK:
Properties props = new Properties();
props.put("bootstrap.servers", "b-1.mskcluster.kafka:9092");
props.put("group.id", "test-group");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
KafkaConsumer consumer = new KafkaConsumer<>(props);
consumer.subscribe(Collections.singletonList("my-topic"));
consumer.poll(Duration.ofMillis(100));
The consumer throws a runtime error about deserializer class not found. What is the likely cause?
AThe topic name is invalid.
BThe bootstrap server address is wrong.
CThe deserializer class names are incorrect or misspelled.
DThe group.id property is missing.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the error message

    The error says deserializer class not found, so the problem is with deserializer class names.
  2. Step 2: Check deserializer class names in code

    They must be fully qualified and spelled exactly. Any typo causes class not found error.
  3. Final Answer:

    The deserializer class names are incorrect or misspelled. -> Option C
  4. Quick Check:

    Deserializer class error = wrong class name [OK]
Quick Trick: Check spelling of deserializer class names first [OK]
Common Mistakes:
  • Ignoring class name typos
  • Assuming bootstrap server causes deserializer error
  • Missing group.id but error is about deserializer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes