0

i am using Spring Boot 2.7 with server.shutdown=graceful. I have an issue with open SSE connections, as those do not terminate during the graceful shutdown.

I get the following:

2023-01-03 17:50:20.079  INFO 39014 --- [tomcat-shutdown] o.s.b.w.e.tomcat.GracefulShutdown        : Graceful shutdown aborted with one or more requests still active

I would like to terminate all the SSE connections during the graceful shutdown, so that the server can stop quicker, and not wait for the 30s timeout for connections that won't ever finish.

I tried using @PreDestroy on my bean, but it is invoked after the graceful shutdown, and thus doesn't work.

Is there another Spring hook i could use to close the open SSE connections during the graceful shutdown?

gotson
  • 3,613
  • 1
  • 23
  • 40

1 Answers1

0

I managed to solve this by implementing SmartLifecycle on my controller. The stop method will be called during the shutdown phase, and cleanup can be done there.

gotson
  • 3,613
  • 1
  • 23
  • 40