GH-2796: Fix partition count related issues (#2807)
If a target middleware (Kafka for ex) topic has more partitions than what is set on the partition-count producer property, the binder never updates the original producer partition-count property to the partition count from the middleware if it is higher than what was given through the property. Because of this, te PartitionAwareFunctionWrapper which evaluates and assigns the partition header in Spring Cloud Stream does not compute the correct partition since the hash operation still using the original partition-count from the producer binding property. This commit is addressing this issue. Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2796
This commit is contained in:
@@ -293,6 +293,14 @@ public class BindingService {
|
||||
validate(producerProperties);
|
||||
Binding<T> binding = doBindProducer(output, bindingTarget, binder,
|
||||
producerProperties);
|
||||
// If the downstream binder modified the partition count in the extended producer properties
|
||||
// based on the higher number of partitions provisioned on the target middleware, update that
|
||||
// in the original producer properties.
|
||||
ProducerProperties originalProducerProperties = this.bindingServiceProperties
|
||||
.getProducerProperties(outputName);
|
||||
if (originalProducerProperties.getPartitionCount() < producerProperties.getPartitionCount()) {
|
||||
originalProducerProperties.setPartitionCount(producerProperties.getPartitionCount());
|
||||
}
|
||||
if (cache) {
|
||||
this.producerBindings.put(outputName, binding);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user