简体   繁体   English

对不同的 kafka 主题使用相同的消费者组

[英]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 )死亡之前存储最后提交的偏移量,因此任何新的消费者线程(如C2CX..属于G1组)将从C1提交的最后一个偏移量开始消费

No, As your不,作为你的

  • C1 is configured to read only from topic T1 and C1 配置为只读主题 T1 和
  • C2 is configured to read only from topic T2 C2 配置为只读主题 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.即使两个消费者的组 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.

相关问题 Kafka 消费者订阅了同一消费者组中的不同主题 - Kafka Consumers subscribed to different topics in same consumer group 使用 Kafka-Python 在 Kafka 中查找消费者组下的主题 - Find the topics under a consumer group in Kafka using Kafka-Python 为什么 Kafka 消费者组要针对不同的主题进行分区撤销? - why Kafka consumer group is doing a partition revoking for different topics? 如果我有相同的消费者组名称来自不同的服务和不同的主题,它会影响 Kafka 性能还是重新平衡影响 - Does It affects Kafka performance or rebalance impact If I have same consumer group name form different service and different topics 不同消费者在同一个消费者组中订阅不同主题的缺点 - Disadvantages of having different consumers subscribed to different topics in same consumer group Kafka:单消费者组,无分区多主题 - Kafka: Single consumer group, no partitions and multiple topics 获取与消费组kafka关联的主题列表 - Get list of topics associated with consumer group kafka 在同一个消费者类中使用多个kafka主题 - Consuming multiple kafka topics in the same consumer class 同一消费者组内具有不同分区数量的不同 kafka 主题 - Different kafka topic with different amount of partitions within the same consumer group 不同 Kafka 主题上的分区是否位于同一消费者(k8s pod)中 - Are partitions on different Kafka topics co-located within same consumer (k8s pod)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM