Question 21 of 50
What is a Consumer?
Question
"What is a Consumer in Kafka?"
What the interviewer wants to assess
Basic architecture knowledge, usually used as a warm-up before deeper questions about Consumer Group, offset, and rebalance.
Resposta rápida
Consumer is any application that reads events from one or more topics, from the position (offset) where it previously stopped. Consumers almost always operate within a Consumer Group, which determines how the topic's partitions are split among the running instances.
Resposta nível Sênior
A consumer is the role played by any application using the Kafka client to read records from partitions.
It doesn't read the topic as a whole — it reads the partitions specifically assigned to it within its
Consumer Group, advancing sequentially from the last committed offset. In Spring Boot, this typically shows
up as a method annotated with @KafkaListener, which receives each deserialized record and processes it
within the application's business logic.
In-depth explanation
See "Consumer" in Chapter 3 and the practical implementation in Chapter 14.
Exemplo financeiro
The notificacao-service is a consumer of the pix.recebido topic: it reads the events assigned to its
partitions and sends a push notification for each one, advancing its own offset independently of other
consumers of the same event.
"A Consumer reads the entire topic"
An individual consumer only reads the partitions assigned to it within its Consumer Group — not the whole topic, unless the topic has only one partition or it's the only consumer in the group.
Pode vir a seguir
Likely follow-ups: "what is a Consumer Group?" and "what is Offset?".
Related chapters