Challenge - 5 Problems
Kafka Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output when a Spring Boot Kafka listener receives a message?
Consider a Spring Boot Kafka listener configured to listen to topic "orders". When a message
"Order123" is sent to this topic, what will the listener method print?Spring Boot
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component; @Component public class OrderListener { @KafkaListener(topics = "orders") public void listen(String message) { System.out.println("Received: " + message); } }
Attempts:
2 left
💡 Hint
The listener method prints a prefix before the message content.
✗ Incorrect
The listener method prints "Received: " followed by the message content it receives from the Kafka topic.
📝 Syntax
intermediate1:30remaining
Which Kafka producer configuration property sets the Kafka server address?
In Spring Boot Kafka producer configuration, which property key correctly sets the Kafka broker address to
localhost:9092?Attempts:
2 left
💡 Hint
The property includes 'producer' and 'bootstrap-servers'.
✗ Incorrect
The correct property to set Kafka broker address for producer is 'spring.kafka.producer.bootstrap-servers'.
🔧 Debug
advanced2:30remaining
Why does this Kafka listener fail to receive messages?
Given the following listener code, why does it not receive messages from the topic
payments?Spring Boot
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component; @Component public class PaymentListener { @KafkaListener(topic = "payments") public void listen(String message) { System.out.println("Payment received: " + message); } }
Attempts:
2 left
💡 Hint
Check the spelling of the annotation property for topic subscription.
✗ Incorrect
The @KafkaListener annotation requires the property 'topics' (plural) to specify the topic list. Using 'topic' causes the listener not to subscribe.
❓ state_output
advanced2:00remaining
What is the value of the message count after processing 3 messages?
A Spring Boot Kafka listener increments a counter each time it receives a message. After receiving 3 messages, what is the value of the counter?
Spring Boot
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component; @Component public class CountingListener { private int messageCount = 0; @KafkaListener(topics = "events") public void listen(String message) { messageCount++; } public int getMessageCount() { return messageCount; } }
Attempts:
2 left
💡 Hint
The counter increments once per message received.
✗ Incorrect
Each message increments messageCount by 1. After 3 messages, messageCount is 3.
🧠 Conceptual
expert3:00remaining
Which option best describes the role of Kafka consumer groups in Spring Boot?
In Spring Boot Kafka integration, what is the main purpose of assigning consumers to the same consumer group?
Attempts:
2 left
💡 Hint
Think about how Kafka distributes messages to consumers in a group.
✗ Incorrect
Consumers in the same group share partitions of a topic so messages are load balanced and processed once per group.