英文:
Spring KafkaListener with topicPattern, assign all paritions of all topics
问题
我有一个使用 topicPattern 和正则表达式的 @KafkaListener,它运行良好(foo.*),但现在我想将该监听器分配到所有匹配主题的所有分区。
https://docs.spring.io/spring-kafka/docs/2.6.1/reference/html/#tip-assign-all-parts 并没有真正帮助我,因为我不知道主题名称。
英文:
I have @KafkaListener using topicPattern with a regex which works just fine (foo.*), but now I want to assign the listener to all partitions of all matching topics.
The <https://docs.spring.io/spring-kafka/docs/2.6.1/reference/html/#tip-assign-all-parts> doesn't really help me as I don't know the topic names.
答案1
得分: 0
当使用模式时,您不能手动分配分区;模式仅支持组管理(Kafka负责分配)。如果您的应用程序只有一个实例,Kafka将为匹配的主题分配所有分区。如果有多个实例,并且您希望它们都分配到所有分区,它们必须具有唯一的“group.id”。
英文:
You can't manually assign partitions when using patterns; only group management (Kafka does the assignment) is supported for patterns.
If there is only one instance of your application, Kafka will assign all the partitions for matching topics. If there are multiple instances and you want them all assigned to all partitions, they must have unique group.id
s.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论