我看很多教程说同一个消费者组里的不同消费者
只能监听同一个主题的不同分区
可是我这个实验发现
同一个主题的同一分区,是可以被同一个消费者组里的不同消费者监听的
可以成功监听到,这是什么道理?
第一个消费者
@KafkaListener(groupId = "consumer01",topicPartitions ={
@TopicPartition(topic = "topicfirst", partitions = { "0" })})
public void receiveMsg0(ConsumerRecord record){
MyLogger.info("partitions 0 receive Msg",this.getClass());
MyLogger.info("partitions 0 topic:"+record.topic(),this.getClass());
MyLogger.info("partitions 0 partitions:"+record.partition(),this.getClass());
MyLogger.info("partitions 0 value:"+record.value(),this.getClass());
}
第二个消费者
@KafkaListener(groupId = "consumer01",topicPartitions ={
@TopicPartition(topic = "topicfirst",