Gracefull shutdown when SSE stream is openned

86 views Asked by At

I have an spring boot 3 back-end application, which does serve also some Flux (SSE, https://www.w3schools.com/html/html5_serversentevents.asp ) event streams. i.e.:

@RequestMapping(path = "/notifications", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ServerSentEvent<OnlineNotificationEvent>> notificationsSse(HttpServletRequest request) {
    // implementation ...
}

I have set up in application.yaml that graceful shutdown should happen:

server:
  port: 9099
  shutdown: graceful

When I open frontend (which opens given sse endpoint), shutdown is not gracefull and it is (I think) waiting for sse endpoint connection to close, till shutdown timeout.

What is the best way to close (finish) sse all opened connections when shutdown request comes? Perhaps same can be applied to websocket connections also.

0

There are 0 answers