Bird
Raised Fist0

Given this producer code snippet using KafkaAvroSerializer:

medium📝 Predict Output Q13 of Q15
Kafka - Schema Registry
Given this producer code snippet using KafkaAvroSerializer:
props.put("schema.registry.url", "http://localhost:8081");
ProducerRecord record = new ProducerRecord<>("topic", userRecord);
producer.send(record);
What happens if userRecord does not match the registered schema?
AA serialization exception is thrown and message is not sent
BThe producer retries sending the message indefinitely
CThe message is sent successfully without validation
DThe message is sent but schema registry logs a warning
Step-by-Step Solution
Solution:
  1. Step 1: Understand KafkaAvroSerializer behavior

    It validates data against the schema before sending.
  2. Step 2: Check what happens on mismatch

    If data doesn't match, serialization fails and an exception is thrown, preventing send.
  3. Final Answer:

    A serialization exception is thrown and message is not sent -> Option A
  4. Quick Check:

    Schema mismatch = serialization error [OK]
Quick Trick: Mismatch triggers serialization exception, no send [OK]
Common Mistakes:
MISTAKES
  • Assuming message sends without validation
  • Thinking producer retries endlessly
  • Believing only warnings are logged

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes