Open ferblaca opened 1 week ago
I have created the PR https://github.com/spring-cloud/spring-cloud-stream/pull/3032 that fixes the issue.
Apparently, the problem was that the configuration classes were being registered in the binder context before the Environment of the context had the list of property sources, so the property conditionals of the classes never matched.
Describe the issue It seems there are issues when configuring conditional sources for a binder in a multi-binder scenario (at least).
To explain the problem, I have created a simple application that you can find in this repository on the branch
issue-binder-factory-sources-order
.I have created a simple configuration
KafkaProducerConsumerConfiguration
that customizes theclientId
value of Kafka clients, which is conditional on the existence of a property value:I have added the configuration to the Kafka binders using the
spring.main.sources
property as follows:The problem is that the binder context, during its registration with DefaultBinderFactory, does not seem to have the propertySources to correctly evaluate the
ConditionalOnProperty
condition, and therefore the application does not customize the clientId's of the Kafka clients.To Reproduce Steps to reproduce the behavior:
consumerConfigCustomizer
andproducerConfigCustomizer
beans.Version of the framework Spring-Boot 3.3.4 Spring-Cloud 2023.0.3
Expected behavior The
KafkaProducerConsumerConfiguration
class is correctly configured, and the following logs are displayed when the application starts:Additional context To verify that the problem is the
ConditionalOnProperty
, comment out that line and restart the application to see the expected result.