so I'm always quite confused when it comes to Flux objects and everything related to them.
In my usecase I have a reactive endpoint exposed to webclient which I want to publish async elements received by spring. My code should look like the following:
@EventListener
@Async
protected void handleModelChanges(ModelChangeEvent e) {
log.debug("Event received {}", e);
// TODO publish event on flux?
}
@GetMapping
public Flux<@NonNull MyModel> modelChanges() {
// TODO
}
I'm quite lost on how to implement this. I want the client to receive events once they connect in an async way. I don't want them to receive old events.
How do I do this?
@fer-marinoWhat exactly do you want to do with @GetMapping? This is more like a server that serves a resource, as you probably know. I think you would understand better how to send events with Project Reactor by using the appropriate configuration, using the tryEmitNext method with Sinks.many() and autoCancel set to false, in publisher and subscriber mode, ApplicationEventPublisher is generally used with @EventListener.