0
0
Kafkadevops~10 mins

Deserialization 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 specify the deserializer for the Kafka consumer.

Kafka
props.put("value.deserializer", [1]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.StringSerializer"
B"org.apache.kafka.common.serialization.IntegerSerializer"
C"org.apache.kafka.common.serialization.StringDeserializer"
D"org.apache.kafka.common.serialization.ByteArraySerializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a serializer class instead of a deserializer.
Confusing key and value deserializers.
2fill in blank
medium

Complete the code to create a Kafka consumer with the correct deserializer for keys.

Kafka
Consumer<String, String> consumer = new KafkaConsumer<>(props, new [1](), new StringDeserializer());
Drag options to blanks, or click blank then click option'
ALongDeserializer
BIntegerDeserializer
CByteArrayDeserializer
DStringDeserializer
Attempts:
3 left
💡 Hint
Common Mistakes
Using a deserializer that does not match the key type.
Using a serializer instead of a deserializer.
3fill in blank
hard

Fix the error in the deserializer class name to correctly deserialize JSON messages.

Kafka
props.put("value.deserializer", [1]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.JsonDeserializer"
B"org.apache.kafka.common.serialization.JsonSerializer"
C"org.apache.kafka.common.serialization.ByteArraySerializer"
D"org.apache.kafka.common.serialization.StringDeserializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using serializer class names instead of deserializer.
Using StringDeserializer for JSON data.
4fill in blank
hard

Fill both blanks to configure the consumer to deserialize keys as strings and values as JSON.

Kafka
props.put("key.deserializer", [1]);
props.put("value.deserializer", [2]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.StringDeserializer"
B"org.apache.kafka.common.serialization.IntegerDeserializer"
C"org.apache.kafka.common.serialization.JsonDeserializer"
D"org.apache.kafka.common.serialization.ByteArrayDeserializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up key and value deserializers.
Using serializer classes instead of deserializers.
5fill in blank
hard

Fill all three blanks to create a Kafka consumer that deserializes keys as strings, values as JSON, and sets the group ID.

Kafka
props.put("key.deserializer", [1]);
props.put("value.deserializer", [2]);
props.put("group.id", [3]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.StringDeserializer"
B"org.apache.kafka.common.serialization.JsonDeserializer"
C"my-group-id"
D"org.apache.kafka.common.serialization.IntegerDeserializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to set the group ID.
Using serializer classes instead of deserializers.