2 Consumers of same topic
See original GitHub issueFriends,
Since using the latest version of spring cloud and spring-cloud-stream-binder-kafka-streams:3.2.1
I lost the ability to have 2 consumers against the same topic. The spring code actually creates the binder proxy against the topic name. Since another already exists it throws a duplicate bean exception. Another project I am using spring-cloud-stream-binder-kafka-streams:3.0.9.RELEASE and I don’t have this problem. Another use posted this issue but then closed it so perhaps its a config thing.
My config is quite basic.
spring:
cloud:
stream:
function:
definition: func1,func2
bindings:
func1-in-0:
destination: topic1
func2-in-0:
destination: topic1
The root issue is that a bean is put as the topic name.
KafkaStreamsBindableProxyFactory.bindInput
private void bindInput(ResolvableType arg0, String inputName) {
if (arg0.getRawClass() != null) {
KafkaStreamsBindableProxyFactory.this.inputHolders.put(inputName,
new BoundTargetHolder(getBindingTargetFactory(arg0.getRawClass())
.createInput(inputName), true));
}
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
RootBeanDefinition rootBeanDefinition = new RootBeanDefinition();
rootBeanDefinition.setInstanceSupplier(() -> inputHolders.get(inputName).getBoundTarget());
registry.registerBeanDefinition(inputName, rootBeanDefinition);
}
In older versions and my other project kafka streams uses the binding name: func1-in-0 in the code above but the latest version use topic name. The documentation still defines the configuration the same in both versions.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
Quick response thanks and I am glad its not a bug.
Thank you.