[英]Kafka Consumer from different group consuming from different partition of Topic
I have a scenario where I have deployed 4 instances of Kafka Consumer on different nodes. 我有一个场景,其中我在不同的节点上部署了4个Kafka Consumer实例。 My topic has 4 partitions.
我的主题有4个分区。 Now, I want to configure the Consumers in such a way that they all fetch from different partitions of the topic.
现在,我要配置使用者,使它们都从主题的不同分区获取。
I know for a fact that if the Consumers are from the same consumer group, they ensure that the partitions are split equally. 我知道一个事实,即如果使用者来自相同的使用者组,他们将确保分区被平均分配。 But in my case, they are not in the same group.
但就我而言,它们不在同一个组中。
In order to achieve what you want you need the consumers being in the same consumer group. 为了实现您想要的目标,您需要将消费者置于同一个消费者组中。 Only in this case a "competing consumer" pattern is applied : each consumer receives 1 partition from the 4, so you have 4 consumers each one reading from 1 partition and receiving messages for that partitions.
仅在这种情况下,才应用“竞争使用者”模式:每个使用者从4个中接收1个分区,因此您有4个使用者,每个使用者从1个分区中读取并接收该分区的消息。 When consumers are part of different consumer groups, each consumer will be assigned to all 4 partitions receiving messages from all of them in a publish/subscribe way.
当使用者属于不同使用者组的一部分时,会将每个使用者分配到所有4个分区,以发布/订阅的方式从所有分区接收消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.