[英]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.我有两个不同的 kafka 主题 T1 和 T2,分别有一个消费者 C1 和 C2。 C1 and C2 have the same consumer group G1. C1 和 C2 具有相同的消费组 G1。 Now, if C1 dies, will C2 consumes message from both the topics T1 and T2?现在,如果 C1 死了,C2 会同时消费来自主题 T1 和 T2 的消息吗?
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
Kafka 将在G1
组消费者线程(即C1
)死亡之前存储最后提交的偏移量,因此任何新的消费者线程(如C2
或CX..
属于G1
组)将从C1
提交的最后一个偏移量开始消费
No, As your不,作为你的
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.即使两个消费者的组 id 相同,它在检查最后提交的偏移量时也能正常工作,但会根据 groupid 和主题进行检查。
As topics here are different T1 & T2, consumers C1 & C2 consumes only from the respective topics T1 & T2.由于这里的主题是不同的 T1 和 T2,消费者 C1 和 C2 仅从各自的主题 T1 和 T2 消费。
To your question "If C1 dies, whether C2 will consume from T1?".对于您的问题“如果 C1 死亡,C2 是否会从 T1 消耗?”。 No, as C2 did not subscribe the T2 topic.不,因为 C2 没有订阅 T2 主题。 So, irrespective of same or different groupid, C2 doesnt consume from T1 as it did not subscribe it.因此,无论 groupid 相同还是不同,C2 都不会从 T1 消费,因为它没有订阅它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.