Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the bootstrap servers for Kafka producer configuration.
Kafka
props.put("bootstrap.servers", [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using zookeeper port 2181 instead of Kafka broker port 9092.
Omitting the port number.
Using an IP without port.
✗ Incorrect
The bootstrap.servers property requires the Kafka broker address with port, typically localhost:9092 for local setups.
2fill in blank
mediumComplete the code to set the key serializer class for Kafka producer.
Kafka
props.put("key.serializer", [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using deserializer class instead of serializer.
Using wrong serializer for key type.
✗ Incorrect
The key.serializer must be a serializer class, here StringSerializer is correct for string keys.
3fill in blank
hardFix the error in setting the 'acks' configuration for Kafka producer to ensure all replicas acknowledge.
Kafka
props.put("acks", [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1' which waits only for leader acknowledgement.
Using '0' which disables acknowledgement.
✗ Incorrect
Setting 'acks' to 'all' ensures the leader waits for all replicas to acknowledge the record.
4fill in blank
hardFill both blanks to configure the producer retries and retry backoff time.
Kafka
props.put("retries", [1]); props.put("retry.backoff.ms", [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting retries to 0 disables retries.
Setting retry.backoff.ms too high causes delays.
✗ Incorrect
Setting retries to 3 allows 3 retry attempts, and retry.backoff.ms to 100 sets 100ms delay between retries.
5fill in blank
hardFill all three blanks to configure the consumer group id, enable auto commit, and set auto commit interval.
Kafka
props.put("group.id", [1]); props.put("enable.auto.commit", [2]); props.put("auto.commit.interval.ms", [3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using false for enable.auto.commit disables auto commit.
Setting auto.commit.interval.ms too low or too high affects performance.
✗ Incorrect
group.id identifies the consumer group, enable.auto.commit true enables auto commit, and auto.commit.interval.ms sets commit interval to 1000ms.