What will happen If partitionCount (spring.cloud.stream.bindings..producer.partitionCount) is greater than 1 and consumer.partitioned (spring.cloud.stream.bindings..consumer.partitioned) is false (Using Kafka)
Advertisement
Answer
In the case of Kafa binder, the property spring.cloud.stream.bindings..consumer.partitioned
is not relevant. You can skip setting this property on the consumer side. This property’s default value is false
. Since Kafka has built-in partitioning support, the binder will simply delegate to Kafka broker and Kafka decides on which partitions to consume from. If you only have one consumer, then it will consume from all the partitions. If you have more than one consumer, Kafka will do a rebalance and split the partitions across the available consumers (assuming that the autoRebalanceEnabled
property remains true
to it’s default value).
You can set spring.cloud.stream.bindings..consumer.partitioned
to true, if you want to set instance index id on the consumers (for e.g if you want to run the app on certain platforms or achieve static partitioning). In this case, you need to provde the instance index or list of instance index to the consumer. However, I think this is irrelvant for your use case.
The upshot here is that you can safely ignore, spring.cloud.stream.bindings..consumer.partitioned
on the consumer side if you are using Kafka binder and auto rebalance is enabled.
We have some basic partitioning samples here that you may want to take a look at.