二,分组消费的再平衡策略
当一个group中,有consumer加入或者离开时,会触发partitions均衡partition.assignment.strategy,决定了partition分配给消费者的分配策略...这种方式有两点要求
A),在实例化每个消费者时给每个topic指定相同的流数
B),每个消费者实例订阅的topic必须相同
Map topicCountMap = new...HashMap();
topicCountMap.put(topic, new Integer(1));
Map<String, List<KafkaStream<byte...这种策略的具体分配步骤:
1),对所有topic的所有分区按照topic+partition转string之后的hash进行排序
2),对消费者按字典进行排序
3),然后轮训的方式将分区分配给消费者
3...ending
* up on one consumer (if it has a high enough stream count).
*/
//按照hash值进行排序