0
0
Kafkadevops~10 mins

Schema validation in producers in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to configure the producer to use schema validation.

Kafka
props.put("schema.registry.url", [1]);
Drag options to blanks, or click blank then click option'
A"localhost:9092"
B"http://localhost:8081"
C"http://localhost:9092"
D"http://schema-registry:9092"
Attempts:
3 left
💡 Hint
Common Mistakes
Using Kafka broker address instead of schema registry URL.
Omitting the protocol (http://) in the URL.
2fill in blank
medium

Complete the code to set the producer's key serializer for Avro schema validation.

Kafka
props.put("key.serializer", [1]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.ByteArraySerializer"
B"org.apache.kafka.common.serialization.StringSerializer"
C"io.confluent.kafka.serializers.KafkaAvroSerializer"
D"org.apache.kafka.common.serialization.IntegerSerializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using StringSerializer instead of KafkaAvroSerializer for Avro data.
Using ByteArraySerializer which does not validate schema.
3fill in blank
hard

Fix the error in the producer configuration to enable schema validation for the value serializer.

Kafka
props.put("value.serializer", [1]);
Drag options to blanks, or click blank then click option'
A"io.confluent.kafka.serializers.KafkaAvroSerializer"
B"org.apache.kafka.common.serialization.StringSerializer"
C"org.apache.kafka.common.serialization.ByteArraySerializer"
D"io.confluent.kafka.serializers.KafkaAvroDeserializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using KafkaAvroDeserializer instead of KafkaAvroSerializer for producer value serializer.
Using StringSerializer which does not validate Avro schema.
4fill in blank
hard

Fill both blanks to create a producer configuration that enables schema validation and sets the schema registry URL.

Kafka
props.put([1], [2]);
Drag options to blanks, or click blank then click option'
A"schema.registry.url"
B"bootstrap.servers"
C"http://localhost:8081"
D"localhost:9092"
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing bootstrap servers with schema registry URL.
Using Kafka broker address instead of schema registry URL.
5fill in blank
hard

Fill all three blanks to configure a Kafka producer with schema validation for both key and value serializers and the schema registry URL.

Kafka
props.put("key.serializer", [1]);
props.put("value.serializer", [2]);
props.put("schema.registry.url", [3]);
Drag options to blanks, or click blank then click option'
A"io.confluent.kafka.serializers.KafkaAvroSerializer"
B"org.apache.kafka.common.serialization.StringSerializer"
C"http://localhost:8081"
D"localhost:9092"
Attempts:
3 left
💡 Hint
Common Mistakes
Using StringSerializer for key or value when Avro schema validation is needed.
Not setting the schema registry URL or setting it incorrectly.