spring-attic/spring-cloud-stream-binder-kafka

streamConfigGlobalProperties overriden for subsequent functions

Closed this issue · 2 comments

Given an application with multiple functions using Kafka Streams Binder:

spring.cloud.stream.function.definition=function1,function2,function3

spring.cloud.stream.bindings.function1-in-0.destination=topic1-in
spring.cloud.stream.bindings.function1-out-0.destination=topic1-out

spring.cloud.stream.bindings.function2-in-0.destination=topic2-in
spring.cloud.stream.bindings.function2-out-0.destination=topic2-out
spring.cloud.stream.kafka.streams.bindings.function2-in-0.consumer.configuration.spring.json.value.type.method=com.test.MyClass.determineType

spring.cloud.stream.bindings.function3-in-0.destination=topic3-in
spring.cloud.stream.bindings.function3-out-0.destination=topic3-out

I would expect that that the specific configuration added for the consumer in the function2 binding, would apply only to that binding.

However, in reality the observed behaviour while debugging is that the functions are initialised alphabetically and when the following line is executed during function2 initialisation:

https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/blob/a8c948a6b25699abfdededc42cf371970bdf04e4/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/AbstractKafkaStreamsBinderProcessor.java#L274

The streamConfigGlobalProperties bean is updated with the additional configuration specific to function2; so when function3 is initialised the extra configuration from function2 is carried over.

Version of the framework
Spring Boot 2.5.1
Spring Cloud 2020.0.3

@yanayita Thanks for this report. This problem is now addressed. Changes are in main upstream and backported to 3.1.x.

Excellent. Thanks @sobychacko !