Bird
0
0

What is the main purpose of using a poll() method inside a Kafka consumer loop?

easy📝 Conceptual Q11 of 15
Kafka - Consumers
What is the main purpose of using a poll() method inside a Kafka consumer loop?
ATo send messages to Kafka topics
BTo continuously fetch new messages from Kafka topics
CTo close the consumer connection
DTo create a new Kafka topic
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of poll() in Kafka consumer

    The poll() method is used to fetch messages from Kafka topics.
  2. Step 2: Recognize the loop usage

    Using poll() inside a loop allows the consumer to keep listening and fetching new messages continuously.
  3. Final Answer:

    To continuously fetch new messages from Kafka topics -> Option B
  4. Quick Check:

    poll() fetches messages repeatedly [OK]
Quick Trick: poll() inside loop fetches messages repeatedly [OK]
Common Mistakes:
  • Thinking poll() sends messages
  • Confusing poll() with closing connection
  • Assuming poll() creates topics

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes