You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the clientId value of Kafka clients, which is conditional on the existence of a property value:
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:
Start the application
Check that the application logs do not show the INFO logs of the consumerConfigCustomizer and producerConfigCustomizer 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:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ |'_| | '_ \/ _`|\ \ \ \\\/ ___)||_)||||||| (_|| ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.3.4)2024-11-06T16:43:40.017+01:00 INFO 12647 --- [ main] e.d.s.KafkaProducerConsumerConfiguration : Customizing producer client id for binding: foo-out-02024-11-06T16:43:40.139+01:00 INFO 12647 --- [ main] e.d.s.KafkaProducerConsumerConfiguration : Customizing consumer client id for binding: completeConsumer1-in-02024-11-06T16:43:40.356+01:00 INFO 12647 --- [ main] e.d.s.KafkaProducerConsumerConfiguration : Customizing consumer client id for binding: completeConsumer2-in-0
Additional context
To verify that the problem is the ConditionalOnProperty, comment out that line and restart the application to see the expected result.
The text was updated successfully, but these errors were encountered:
ferblaca
pushed a commit
to ferblaca/spring-cloud-stream
that referenced
this issue
Nov 7, 2024
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.The text was updated successfully, but these errors were encountered: