Spring KafkaListener with topicPattern, assign all paritions of all topics

huangapple go评论131阅读模式
英文:

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.ids.

huangapple
  • 本文由 发表于 2020年10月7日 23:08:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/64246965.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定