I need to declare multiple Fanout exchanges
@SpringBootApplication
public class Application {
@Bean
FanoutExchange exchange1() {
return new FanoutExchange(exchangeName1, true, false);
}
@Bean
FanoutExchange exchange2() {
return new FanoutExchange(exchangeName2, true, false);
}
....
....
}
As soon as I add the code for the exchange2
I get the error:
APPLICATION FAILED TO START
Description:
Parameter 1 of method binding in com.Application required a single bean, but 2 were found: - exchange1: defined by method 'exchange1' in com.Application - exchange2: defined by method 'exchange2' in com.Application
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed