分区计数覆盖

Partition Count override

从这里 https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/blob/master/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java 看来不可能,但还是要问一下,以防我错过了。

在Spring云数据流中,尝试创建流,但需要为主题设置自定义分区。

分区数似乎是根据应用程序的实例数计算的。有什么方法可以覆盖主题上使用的分区数量吗?必须在队列的两侧(消费者,生产者)设置它们,但这不是问题。

提前致谢

您可以通过设置覆盖默认行为:--spring.cloud.stream.kafka.binder.minPartitionCount=<CUSTOM_VALUE>

请注意 reference guide 中为此 属性 描述的先决条件。

此外,您会发现指南中的以下注意事项通常很有用。

"The Kafka binder uses the partitionCount setting of the producer as a hint to create a topic with the given partition count (in conjunction with the minPartitionCount, the maximum of the two being the value being used). Exercise caution when configuring both minPartitionCount for a binder and partitionCount for an application, as the larger value is used. If a topic already exists with a smaller partition count and autoAddPartitions is disabled (the default), the binder fails to start. If a topic already exists with a smaller partition count and autoAddPartitions is enabled, new partitions are added. If a topic already exists with a larger number of partitions than the maximum of (minPartitionCount or partitionCount), the existing partition count is used."

至于 SCDF,您可以从 Shell 或 UI 为 App 覆盖此 属性。如果您希望将其全局应用于所有 Stream 应用程序,那也是可能的 - 请参阅 here.