0
0
Kafkadevops~5 mins

Consumer API basics in Kafka - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main role of a Kafka Consumer?
A Kafka Consumer reads data from Kafka topics. It subscribes to topics and processes the messages sent by producers.
Click to reveal answer
beginner
What does 'subscribe()' method do in Kafka Consumer API?
The subscribe() method tells the consumer which topics to listen to. It allows the consumer to receive messages from those topics.
Click to reveal answer
beginner
Explain what 'poll()' method does in Kafka Consumer API.
The poll() method fetches records from the Kafka broker. It waits for new messages and returns them for processing.
Click to reveal answer
intermediate
Why is committing offsets important in Kafka Consumer?
Committing offsets tells Kafka which messages have been processed. This helps avoid processing the same message twice after a restart.
Click to reveal answer
intermediate
What is the difference between automatic and manual offset commit?
Automatic commit happens periodically without user control, while manual commit lets the user decide when to save the offset after processing messages.
Click to reveal answer
What method does a Kafka Consumer use to start receiving messages from a topic?
Asubscribe()
Bconnect()
Csend()
Dcommit()
Which method fetches messages from Kafka for the consumer to process?
Aread()
Bfetch()
Creceive()
Dpoll()
Why do consumers commit offsets?
ATo send messages to Kafka
BTo mark messages as processed
CTo subscribe to topics
DTo create new topics
What happens if a consumer does not commit offsets?
AIt may reprocess messages after restart
BIt will lose messages permanently
CIt cannot subscribe to topics
DIt will send duplicate messages
Which of these is a valid way to control offset commits?
AProducer acknowledgments
BAutomatic topic creation
CManual commit
DBroker replication
Describe the basic steps a Kafka Consumer takes to read messages from a topic.
Think about how the consumer connects, gets data, and remembers progress.
You got /4 concepts.
    Explain why offset management is important in Kafka Consumer API.
    Consider what happens if the consumer restarts.
    You got /4 concepts.