Server-Sent Events in Spring

最后发布时间:2023-12-10 21:18:14 浏览量:

https://www.baeldung.com/spring-server-sent-events

SSE with Spring 5 Webflux

@GetMapping(path = "/stream-flux", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<String> streamFlux() {
    return Flux.interval(Duration.ofSeconds(1))
      .map(sequence -> "Flux - " + LocalTime.now().toString());
}