I have a service that wants to receive events from multiple sources, and do the same thing with all of them. In attempt to reduce the amount of code I need to write, I'd like to have multiple queues point to the same consumer.
eg:
#application.yml
...
bindings:
myEventConsumer-in-0:
binder: binder1
destination: my-event.exchange
contentType: application/json
group: ${some-group}
myEventConsumer-in-0:
binder: binder2
destination: my-event.exchange
contentType: application/json
group: ${some-group}
MessagingConfig.java
package my.config
import ...
@Configuration
public class MessagingConfig {
@Bean
Consumer<Event<someEventCreate>> myEventConsumer(myService myService) {
return new MyEventConsumer(myService);
}
}
Is it possible using the application.yml config to have multiple bindings pointing to the same consumer? With the configuration above we have duplicate key errors so obviously that's not going to work, but is there another way?