Search code examples
springspring-cloudspring-cloud-streamspring-cloud-dataflow

Spring Cloud Stream Processor from two different Kafka broker


I would like to know whether is possible or not to bind two different Kafka broker for the input and output on Spring Cloud Stream.

In other words, I would like my stream to be listening in one Kafka broker and write the output in other Kafka broker.

@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Object handle(String message) {
    // Processor.INPUTbeing bind to one Kafka broker
    // Processor.OUTPUT being bind to another Kafka broker
    // Write the logic here
}

Solution

  • Yes, very much, you can! Here's a multi-binder application that reads from and writes to 2 different Kafka clusters.

    Pay attention to the binder and the channel binding configurations in the application.yml.