-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Provide a constant for graceful shutdown's smart lifecycle phase #24255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This comment has been minimized.
This comment has been minimized.
We're not sure about adding a new event, but we do want to improve the documentation and perhaps add some constants so that things are clearer. |
Putting the constants on |
We've got two smart lifecycle classes at the moment:
It might be a bit confusing to have a constant defined on both of them. The alternative would be a common smart lifecycle in We were keen to keep the constructors package-private. Flagging for team attention to see if we'd rather keep the separate smart lifecycles with package-private constructors and have two constants, or a single smart lifecycle and constant but with a public constructor. |
I like the single class, it seems less confusing than duplicated constants. |
Upon graceful shutdown the application will wait for a configurable timeout before killing the webserver and continuing with the termination of the rest of the application. Graceful shutdown is currently happening after
ContextClosedEvent
is published and before beans are destroyed, during lifecycle stop.Our application publishes information about all serviced requests to an external data source. We're typically not interested in the requests that were terminated inflight by the graceful shutdown but are interested in the ones that finished after the shutdown was triggered. The logger publishing this information is async and we would like to flush it after the webserver has finished servicing all live requests and has been terminated and only then terminate the logger.
Currently we can achieve this with a
SmartLifecycle
bean whose phase is later than that of beanwebServerGracefulShutdown
. BeanwebServerGracefulShutdown
has the default phase but this is not documented and the class is not public, so this feels a bit hacky. Alternatively, we could terminate our logger onContextClosedEvent
. However, this way we would be dropping the logging of all the requests that finished being serviced during graceful shutdown.There's a
WebServerInitializedEvent
. Would having a similar event for termination make sense?I think
@PreDestroy
would also be an option but I'm not sure it might be the desired interface in this or similar situations.The text was updated successfully, but these errors were encountered: