'Can we have spring cloud stream working with just the application.yml properties?

I need to create an application which has to bridge multiple Queue solutions like Rabbitmq, Kafka, Azure eventhub. I am thinking to use Spring cloud Stream so that i can define the bridge rules in the application.yml. Ex, I want to consume a message from Kafka1(Topic: Test) to Rabbitmq(Queue: Test1) and RabbitMq(Queue: Test2) to Kafka(Topic: Test3).To achieve this rite now I have to create two functions one for each and able to transfer the messages. But in few days, If i want to add one more transfer, then i had to change the code for it. Is there anyway where i can do the binding without writing the function in Spring cloud stream ?

Currently I can achieve this like below

spring:
  cloud:
    stream:      
      bindings:      
        receive-in-0:
          destination: test          
          type: kafka
        receive-out-0:          
          destination: test1         
          type: rabbit
      
        receive1-in-0:          
          destination: test2         
          type: rabbit              
        receive1-out-0:
          destination: test3
          type: kafka
      function:
        definition: receive;receive1
      

I created receive and receive1 function like below as two beans.

  @Bean
  public Function<String, String> receive() {
      return foo -> foo;
  }
  
  @Bean
  public Function<String, String> receive1() {
      return foo -> foo;
  }

What i want is to avoid creating this beans so that i can add 'N' number of such transfers just by giving the topic and broker types.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source