emilly
emilly

Reputation: 10538

Message delivered to one consumer per group?

I have two consumer group i.e G1 and G2.

  1. G1 has two members M1,M2.
  2. G2 has again two members M3,M4

G1 polls the Kafka topic, will message be delivered to only one member either M1 or M2 here not both ?

Similarly when G2 polls after sometime, It will still find message on topic. Here also wither M3 or M4 will receive the message ?

Also I believe all member in group should be on same node. Right ? Is the responsibility of client code or Kafka to select the specific member in a group ?

Upvotes: 1

Views: 1008

Answers (1)

Hans Jespersen
Hans Jespersen

Reputation: 8335

The answer to your question depends on how many partitions there are in the topic(s) these consumer groups are consuming from. Only one member of a consumer group can read from each partition of a topic.

If there is only one partition in topic T1 then M1 and M3 would read from it and M2 and M4 would get no messages.

If there are two partition in T1 (say P1 and P2) then M1 and M3 would get the messages from T1P1 and M2 and M4 would get the messages from T1P2

All the members of a consumer group do not have to be on the same node

One of the brokers is designated as the group’s coordinator and is responsible for managing the members of the group as well as their partition assignments.

Upvotes: 1

Related Questions