spring boot – Forward ApplicationEvent to RabbitMQ using funtions

My application should spread some event from a component to some rabbit message publisher.

My component fires the event using ApplicationEventPublisher.publishEvent(e)

On the other side, a message producer should receive the event, process it then publish it to a rabbit queue.

I’m using spring cloud stream and spring cloud function for messaging part:

@Configurationn
MessagingConfig {
@Autowired
StreamBridge sb; 

@EventListener
void handleEvent(Event e){
sb.send("topic", e)
}

Is there to rely on function rather StreamBridge

@Bean
Supplier<Event> messageProducer(){
//Get the event and publish it
}

Or considering ApplicationEventListener as binder

Function<Event, Event> messageProcessor(){
// redirect event to rabbit binder
}

I’m a confused.
Thank you for your help.

Read more here: Source link