消息传递给每个组的一个消费者? [英] Message delivered to one consumer per group?

查看:22
本文介绍了消息传递给每个组的一个消费者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个消费者组,即 G1 和 G2.

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

  1. G1 有两个成员 M1,M2.
  2. G2 又有两个成员 M3、M4

G1 轮询 Kafka 主题,消息会不会只传递给 M1 或 M2 中的一个成员,而不是同时传递给两个成员?

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

类似的,当 G2 轮询一段时间后,它仍然会找到关于主题的消息.这里也有凋灵M3或M4会收到消息?

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

另外我相信组中的所有成员都应该在同一个节点上.对 ?是客户端代码还是Kafka负责选择组中的特定成员?

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 ?

推荐答案

您问题的答案取决于这些消费者组正在消费的主题中有多少个分区.一个消费者组的一个成员只能从一个主题的每个分区中读取.

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.

如果主题 T1 中只有一个分区,则 M1 和 M3 会从中读取数据,而 M2 和 M4 不会收到任何消息.

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.

如果 T1 中有两个分区(比如 P1 和 P2),那么 M1 和 M3 将从 T1P1 获取消息,而 M2 和 M4 将从 T1P2 获取消息

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.

这篇关于消息传递给每个组的一个消费者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆