Closed jbrelje closed 1 month ago
Could you put this together in a runnable app? Please remove all the security configurations. If there is an underlying issue, it should be reproducible without any security config. Also, can you try not using the function/binding names as application id's? I don't think that matters, but it's worth a try. Thanks!
thank you for the response!
I have pushed a demo here: https://github.com/jbrelje/multiple-kstreams-demo
While sanitizing the demo app, I believe I have found the root of the issue. It seems that if the @Configuration
class contains two methods with the same name, then the behavior is inconsistent on start up. If the functional bindings are uniquely named, I am getting the expected behavior. The demo I pushed showcases the duplicate named methods that seem to be causing the issue.
I was able to resolve the issues locally by simply altering the method names, but figured I would share anyways.
@jbrelje, I am curious how you ended up having the same method names in the same configuration class. Did you have two separate inner classes in the same configuration?
No, it was just an oversight.
I assumed since only one was annotated with @Bean
(and they had different signatures) it would be okay.
I tend to think that the workaround is an actual solution. It might be better to name bean methods differently in the same class. Or do you have any use cases to address it any further?
Nope, I agree. That solution is good for me. Thanks for the discussion!
When running an application with multiple functional stream bindings the behavior on application start is inconsistent. Sometimes both bindings are created (as expected), but more often only one or the other is created. Occasionally neither binding is created at all.
When removing one of the bindings and leaving just a single one in place there are no issues with the bindings not being created.
steps to reproduce set below config in
application.yml
create Java class with multiple stream Consumer beans
run the application
see in the logs that sometimes only one stream consumer is working vs both, with no other indicator why. There are no WARN nor ERROR logs. Simply shutting down the application and starting again produces different behavior.
vs
versions Java version 17
org.springframework.boot:spring-boot-starter-parent:3.2.1
org.springframework.cloud:spring-cloud-stream-binder-kafka-streams:4.0.3
Expected behavior Both stream bindings should start and function consistently OR provide more information via logging about what is causing only one to be created.