I want an advise according usage of spring cloud stream technologies. Currently my service use spring-boot and implements some event-based approaches. But the events are not sent to some kind of broker, but are simply handled by handlers in separate threads. I am interested in spring cloud stream technology. I have implemented CustomMessageRoutingCallback as shown in this example https://github.com/spring-cloud/spring-cloud-stream-samples/tree/main/routing-samples/message-routing-callback. But the problem, that declaring all consumers at config in this way sounds like a pain:
@Bean
public Consumer<Menu> menuConsumer(){
return menu -> log.info(menu.toString());
}
Because I have around 50-60 different event types. Is where any way to register consumers dynamicly? Or the better way will be declare consumer with some raw input type, then deserialize message in consumer and manually route message to the right consumer?