Bird
0
0

What will be the output if a Kafka consumer reads from a topic with no new messages?

medium📝 Predict Output Q5 of 15
Kafka - Basics and Event Streaming
What will be the output if a Kafka consumer reads from a topic with no new messages?
AThe consumer will block and wait for new messages.
BThe consumer will restart automatically.
CThe consumer will throw an error and stop.
DThe consumer will return an empty batch immediately.
Step-by-Step Solution
Solution:
  1. Step 1: Understand consumer polling behavior

    Kafka consumers poll for messages and return batches of records.
  2. Step 2: Behavior when no new messages

    If no new messages exist, the consumer returns an empty batch without error or blocking indefinitely.
  3. Final Answer:

    The consumer will return an empty batch immediately. -> Option D
  4. Quick Check:

    No new messages = empty batch returned [OK]
Quick Trick: Consumers return empty batches if no messages found [OK]
Common Mistakes:
  • Expecting consumer to block forever
  • Assuming consumer throws error
  • Thinking consumer restarts automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes