Closed
Description
In Spring 6.2 we got a new WebFlux feature with Fragment
and you can render an SSE like this:
@GetMapping(path = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Fragment> stream() {
return Flux.interval(Duration.ofSeconds(5))
.map(value -> Fragment.create("time", Map.of("value", value, "time", System.currentTimeMillis())));
}
The only potential problem is that it doen't give you control over the SSE fields (in particular the "event" name which is unconditionaly rendered as the view name). If we could send Flux<ServerSentEvent<Fragment>>
it would give us more control.
Same for MVC, but I think that might already be supported (Flux<ServerSentEvent<ModelAndView>>
)?