0

In KafkaBinderConfigurationProperties, there are default properties, producer and consumer specific properties.

And for the API mergedConsumerConfiguration and mergedProducerConfiguration, when merging those properties, these two APIs only consider the Kafka-defined properties

for (Map.Entry<String, String> configurationEntry : this.configuration.entrySet()) {
    if (ProducerConfig.configNames().contains(configurationEntry.getKey())) {
        producerConfiguration.put(configurationEntry.getKey(), configurationEntry.getValue());
    }
}

While comparing with KafkaProperties, it has similar hierarchy of default and client properties. And when merging those properties to each final client property map, it just put all entries without filtering Kafka-defined ones:

private Map<String, Object> buildCommonProperties() {
    Map<String, Object> properties = new HashMap<>();
    if (this.bootstrapServers != null) {
        properties.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, this.bootstrapServers);
    }
    if (this.clientId != null) {
        properties.put(CommonClientConfigs.CLIENT_ID_CONFIG, this.clientId);
    }
    properties.putAll(this.ssl.buildProperties());
    properties.putAll(this.security.buildProperties());
    if (!CollectionUtils.isEmpty(this.properties)) {
        properties.putAll(this.properties);
    }
    return properties;
}

/**
 * Create an initial map of consumer properties from the state of this instance.
 * <p>
 * This allows you to add additional properties, if necessary, and override the
 * default kafkaConsumerFactory bean.
 * @return the consumer properties initialized with the customizations defined on this
 * instance
 */
public Map<String, Object> buildConsumerProperties() {
    Map<String, Object> properties = buildCommonProperties();
    properties.putAll(this.consumer.buildProperties());
    return properties;
}

So there is inconsistency between the merging behavior of Spring Boot and Spring Cloud Stream binder.

I would like to know does Spring Cloud Stream or Spring Boot has the plan to modify the current implementation and keep the same behavior?

ahuemmer
  • 1,653
  • 9
  • 22
  • 29
Yi Liu
  • 83
  • 4

0 Answers0