Challenge - 5 Problems
Kafka Topic Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Kafka topic creation command?
Consider the following Kafka CLI command to create a topic named orders with 3 partitions and a replication factor of 2. What will be the output if the command runs successfully?
Kafka
kafka-topics.sh --create --topic orders --partitions 3 --replication-factor 2 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Think about what the Kafka CLI prints when a topic is created successfully.
✗ Incorrect
When a Kafka topic is created successfully using kafka-topics.sh, the CLI prints 'Created topic .' If the topic already exists, it prints an error. If replication factor is too high, it warns. It does not run silently.
🧠 Conceptual
intermediate1:30remaining
Which property defines the number of partitions when creating a Kafka topic?
When creating a Kafka topic, which configuration property controls how many partitions the topic will have?
Attempts:
2 left
💡 Hint
Look for the property name that clearly relates to partitions count.
✗ Incorrect
The property 'num.partitions' defines how many partitions a Kafka topic will have. 'replication.factor' controls replication, others are invalid.
❓ Predict Output
advanced2:00remaining
What error does this Kafka topic creation command produce?
What error message will this command produce if there is only 1 broker running but the replication factor is set to 3?
Kafka
kafka-topics.sh --create --topic logs --partitions 2 --replication-factor 3 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Replication factor cannot be larger than the number of brokers.
✗ Incorrect
Kafka requires the replication factor to be less than or equal to the number of brokers. If not, it throws an error indicating replication factor is too large.
🚀 Application
advanced1:30remaining
How many partitions will the topic have after this command?
You run this command to create a topic without specifying partitions. The Kafka broker's default number of partitions is set to 4. How many partitions will the new topic have?
Kafka
kafka-topics.sh --create --topic payments --replication-factor 1 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
If partitions are not specified, Kafka uses the broker default.
✗ Incorrect
When partitions are not specified during topic creation, Kafka uses the broker's default number of partitions, which in this case is 4.
🔧 Debug
expert2:30remaining
Why does this topic creation command fail with a syntax error?
Identify the syntax error in this Kafka topic creation command and explain why it fails.
Kafka
kafka-topics.sh --create --topic "user-activity" --partitions 3 --replication-factor 1 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Check the quotes around the topic name carefully.
✗ Incorrect
The command is missing the closing double quote after the topic name, causing the shell to treat the rest as part of the string, leading to a syntax error.