0

I am able to figure it out to consume 2 different Avros with different Topics. but i have 3 Topics with 3 different Avro's. how do we do in Spring Cloud kafka stream. working code with 2 topics:

when I add consumerProcess-in-2, BiConsumer wont identify the 3 avro or 3 topic. which makes sense since this is BiConsumer. Any suggestion would be helpful.

Thank you in advance.

cloud:
    stream:
      function:
        definition: consumerProcess
      bindings:
        consumerProcess-in-0:
          content-type: application/*+avro
          destination: Topic-1
        consumerProcess-in-1:
          content-type: application/*+avro
          destination: Topic-2

public BiConsumer<KStream<String, Avro1>, KStream<String, Avro2>> consumerProcess() {
    return (avro1, avro2) -> {
      avro1.foreach(
          (key, value) -> {
            log.info("Avro1 ({}))",value);
          });
      avro2.foreach(
          (key, value) -> {
            log.info("avro2 {})", value);
          });
    };
Vineet
  • 145
  • 1
  • 1
  • 7
  • Is it a hard requirement to use spring cloud stream? If not I would recommend you to use standard spring-kafka which has kafka-streams support(adding the stream library to the classpath) where you have more control and can easily join multiple topics -> https://docs.spring.io/spring-kafka/docs/current/reference/html/#streams-kafka-streams – groo Apr 28 '22 at 22:09
  • Unfortunately yes. We are using everywhere spring cloud stream. – Vineet Apr 28 '22 at 23:34

0 Answers0