0
0
Kafkadevops~20 mins

Schema Registry concept in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Schema Registry Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Schema Registry API call?
Given a Schema Registry REST API call to get the latest schema for a subject, what is the expected output?
Kafka
curl -X GET http://localhost:8081/subjects/user-value/versions/latest
A{"subjects":["user-key","user-value"]}
B{"error_code":404,"message":"Subject not found"}
C{"id":10,"schema":"{\"type\":\"string\"}"}
D{"subject":"user-value","version":3,"id":10,"schema":"{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"}]}"}
Attempts:
2 left
💡 Hint
The latest schema for a subject returns detailed schema info including subject, version, id, and schema string.
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of a Schema Registry in Kafka?
Choose the best description of what a Schema Registry does in a Kafka ecosystem.
AIt stores and manages schemas for Kafka messages to ensure compatibility and validation.
BIt acts as a message broker to route Kafka messages between producers and consumers.
CIt provides a user interface to monitor Kafka cluster health and metrics.
DIt compresses Kafka messages to reduce network bandwidth usage.
Attempts:
2 left
💡 Hint
Think about how Kafka producers and consumers agree on message formats.
🔧 Debug
advanced
2:30remaining
Why does this Kafka producer fail when using Schema Registry?
A Kafka producer configured with Schema Registry throws an error when sending messages. What is the likely cause?
Kafka
Producer config:
{
  "bootstrap.servers": "localhost:9092",
  "key.serializer": "org.apache.kafka.common.serialization.StringSerializer",
  "value.serializer": "io.confluent.kafka.serializers.KafkaAvroSerializer",
  "schema.registry.url": "http://localhost:8081"
}

Error message: "org.apache.kafka.common.errors.SerializationException: Error serializing Avro message"
AThe key.serializer is incompatible with the value.serializer.
BThe Kafka broker is down and cannot accept messages.
CThe schema for the message value is not registered in the Schema Registry.
DThe producer is missing the bootstrap.servers configuration.
Attempts:
2 left
💡 Hint
SerializationException often means the schema is missing or incompatible.
📝 Syntax
advanced
2:00remaining
Which Avro schema is valid for registering in Schema Registry?
Select the valid Avro schema JSON string that can be registered in Schema Registry.
A{"type":"record","name":"User","fields":[{"name":"id","type":"int"},{"name":"name","type":"string"}]}
B{"type":"record","fields":[{"name":"id","type":"int"},{"name":"name","type":"string"}]}
C{"type":"record","name":"User","fields":{"id":"int","name":"string"}}
D{"type":"record","name":"User","fields":[{"id":"int"},{"name":"string"}]}
Attempts:
2 left
💡 Hint
Avro record fields must be an array of objects with 'name' and 'type' keys.
🚀 Application
expert
3:00remaining
How many schema versions exist after these operations?
You register a schema for subject 'order-value' three times with these schemas: 1) {"type":"record","name":"Order","fields":[{"name":"id","type":"int"}]} 2) {"type":"record","name":"Order","fields":[{"name":"id","type":"int"},{"name":"amount","type":"float"}]} 3) {"type":"record","name":"Order","fields":[{"name":"id","type":"int"},{"name":"amount","type":"float"}]} How many versions will the subject 'order-value' have in Schema Registry?
A0
B2
C1
D3
Attempts:
2 left
💡 Hint
Schema Registry does not create a new version if the schema is identical to the latest one.