Challenge - 5 Problems
Kafka Producer Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why do Kafka producers publish data?
In Kafka, what is the main reason producers publish data to topics?
Attempts:
2 left
💡 Hint
Think about the role of producers in the Kafka messaging system.
✗ Incorrect
Producers send data (messages) to Kafka topics so consumers can read and process them. They do not consume or delete messages.
❓ Predict Output
intermediate2:00remaining
What is the output of this Kafka producer code snippet?
Given this simplified Kafka producer code, what will be printed?
Kafka
from kafka import KafkaProducer producer = KafkaProducer(bootstrap_servers='localhost:9092') future = producer.send('my_topic', b'hello') result = future.get(timeout=10) print(result.topic)
Attempts:
2 left
💡 Hint
The 'result' object contains metadata about the sent message.
✗ Incorrect
The future.get() returns a RecordMetadata object, which has a topic attribute showing the topic name.
🔧 Debug
advanced2:00remaining
Why does this Kafka producer code raise an error?
This Kafka producer code raises an error. What is the cause?
Kafka
from kafka import KafkaProducer producer = KafkaProducer(bootstrap_servers='localhost:9092') producer.send('my_topic', 'hello')
Attempts:
2 left
💡 Hint
Check the data type of the message sent.
✗ Incorrect
KafkaProducer expects the message value as bytes. Sending a string without encoding causes a TypeError.
📝 Syntax
advanced1:30remaining
Which option correctly publishes data to a Kafka topic?
Select the code snippet that correctly sends a message to a Kafka topic.
Attempts:
2 left
💡 Hint
Check the required argument types and names for the send method.
✗ Incorrect
The send method requires the topic name as first argument and the message as bytes. Option C matches this.
🚀 Application
expert2:30remaining
How does a Kafka producer ensure message delivery reliability?
Which configuration setting in Kafka producer controls how many acknowledgments are required to consider a message successfully published?
Attempts:
2 left
💡 Hint
This setting controls how many brokers must confirm the write.
✗ Incorrect
The acks setting controls the number of acknowledgments the producer waits for before considering a message sent successfully.