Recall & Review
beginner
What does it mean to subscribe to a topic in Kafka?
Subscribing to a topic means telling the Kafka consumer which topics it should listen to for new messages. The consumer will then receive messages from those topics.
Click to reveal answer
beginner
How do you subscribe to multiple topics in Kafka using the consumer API?
You provide a list of topic names to the consumer's subscribe method, like consumer.subscribe(Arrays.asList("topic1", "topic2")). This makes the consumer listen to all listed topics.
Click to reveal answer
intermediate
What is the difference between subscribing to topics and assigning partitions in Kafka?
Subscribing lets Kafka manage which partitions the consumer reads from automatically. Assigning partitions means you manually tell the consumer exactly which partitions to read, giving more control but requiring manual management.
Click to reveal answer
intermediate
What happens if a consumer subscribes to a topic that does not exist yet?
The consumer will keep trying to find the topic. If the topic is created later, the consumer will start receiving messages from it. This allows dynamic topic creation.
Click to reveal answer
beginner
Why is it important to call consumer.poll() after subscribing to topics?
Calling consumer.poll() triggers the consumer to fetch messages from the subscribed topics. Without polling, the consumer won't receive any messages.
Click to reveal answer
What method is used to subscribe a Kafka consumer to topics?
✗ Incorrect
The subscribe() method is used to tell the consumer which topics to listen to.
If you want Kafka to automatically manage partition assignment, you should:
✗ Incorrect
subscribe() lets Kafka handle partition assignment automatically.
What happens if you subscribe to a topic that does not exist yet?
✗ Incorrect
Kafka consumers wait for the topic to be created and then start receiving messages.
Which method must be called regularly to receive messages after subscribing?
✗ Incorrect
poll() fetches messages from the subscribed topics.
To listen to multiple topics, you should:
✗ Incorrect
You pass a list of topic names to subscribe() to listen to multiple topics.
Explain how subscribing to topics works in Kafka and why it is useful.
Think about how the consumer knows what to listen to.
You got /4 concepts.
Describe the difference between subscribing to topics and assigning partitions in Kafka.
Consider who manages the partitions in each case.
You got /4 concepts.