Kafka消费者有两种订阅模式,一种是订阅topic,另一种是订阅partition。
订阅topic
kafkaConsumer
.subscribe(Collections
.singletonList("test"));
订阅正则化topic
kafkaConsumer
.subscribe(Collections
.singletonList("test*"));
订阅partition
kafkaConsumer
.assign(Arrays
.asList(new TopicPartition("test", 0)));
转载请注明原文地址:https://tech.qufami.com/read-19359.html