CoderRob
CoderRob

Reputation: 51

Using same consumer group for different kafka topics

I have two different kafka topics T1 and T2, both having one consumer each C1 and C2 respectively. C1 and C2 have the same consumer group G1. Now, if C1 dies, will C2 consumes message from both the topics T1 and T2 ?

Upvotes: 4

Views: 3330

Answers (2)

Surendra S
Surendra S

Reputation: 91

No, As your

  • C1 is configured to read only from topic T1 and
  • C2 is configured to read only from topic T2

Even though group id is same for both the consumers it works fine as while checking the last committed offset, it will be checked against groupid and topic.

As topics here are different T1 & T2, consumers C1 & C2 consumes only from the respective topics T1 & T2.

To your question "If C1 dies, whether C2 will consume from T1 ?". No, as C2 did not subscribe the T2 topic. So, irrespective of same or different groupid, C2 doesnt consume from T1 as it did not subscribe it.

Upvotes: 1

Ryuzaki L
Ryuzaki L

Reputation: 40008

Kafka will store the last committed offset of G1 group consumer thread (which is C1) before it die, and then hence any new consumer thread like either C2 or CX.. belonging to G1 group will start consuming from the last offset committed by C1

Upvotes: 0

Related Questions