hard coder
hard coder

Reputation: 5735

What Happens when there is only one partition in Kafka topic and multiple consumers?

I have a Kafka Topic with only one partition and I am not getting what will happen in following cases? How messages will be delivered to consumers?

  1. If all consumers are in same group
  2. If all consumers are in different group

enter image description here I am not sure if consumers will receive unique messages or duplicate ones.

Upvotes: 6

Views: 5729

Answers (1)

Nishu Tayal
Nishu Tayal

Reputation: 20860

Each Consumer subscribes to a/more partition in a topic. And each consumer belongs to a consumer group. Below are two scenarios:

  1. When all consumers belong to the same group : Each consumer will try to subscribe to a different partition. In case,if there is only one partition, only one consumer will get the messages, while other consumers will be idle.

  2. When all consumers belong to the different consumer group: Each consumer will get the messages from all partitions. Partition subscription is based on the consumer groups.

It depends on the consumer groups. Consumers within the same consumer group don't read the data again from the same partitions once the read offsets have been committed.

Upvotes: 11

Related Questions