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

Spring Cloud Stream binders for Apache Kafka and Kafka Streams
Apache License 2.0
331 stars 301 forks source link

Can we consume messages from multiple topics? #982

Closed uselvvi closed 3 years ago

uselvvi commented 3 years ago

I have some beans in my app like this. I just want to consume the data. We do not write back to kafka topic.

    @Bean
    public Consumer<KStream<String, String>> first(){
        return kstream -> // print;
    };

    @Bean
    public Consumer<KStream<String, String>> second(){
        return kstream -> // print
    };

application.yaml

spring.cloud.stream:
  function:
    defintion: first;second
  bindings:
    first-in-0:
      destination: firstTopic
    second-in-0:
      destination: secondTopic

Why do I get this? How can i consume messages from 2 different topics independently.

java.lang.IllegalStateException: Multiple functions found, but function definition property is not set.