Skip to content
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

Alling getPhase() with Updated Phases for Graceful Shutdown #3030

Open
VedelPeter opened this issue Nov 6, 2024 · 1 comment
Open

Alling getPhase() with Updated Phases for Graceful Shutdown #3030

VedelPeter opened this issue Nov 6, 2024 · 1 comment
Milestone

Comments

@VedelPeter
Copy link

VedelPeter commented Nov 6, 2024

According to https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#updated-phases-for-graceful-shutdown:

Updated Phases for Graceful Shutdown

The phases used by the SmartLifecycle implementations for graceful shutdown have been updated. Graceful shutdown now begins in phase SmartLifecycle.DEFAULT_PHASE - 2048 and the web server is stopped in phase SmartLifecycle.DEFAULT_PHASE - 1024. Any SmartLifecycle implementations that were participating in graceful shutdown should be updated accordingly.

getPhase() for classes InputBindingLifecycle, OutputBindingLifecycle should be aligned too so graceful shutdown is working as excepted

@olegz olegz closed this as completed in aa2b309 Dec 11, 2024
@olegz olegz added this to the 4.2.1 milestone Dec 11, 2024
@josef-pones
Copy link

I tested the proposed solution, and it doesn't work. In our project, the web server receives an HTTP request and converts it into a message. This message is sent via Spring Cloud Stream and RabbitMQ to other services for processing. Meanwhile, the request waits on the web server for a response. Once the message is processed, the waiting request is retrieved, and the response to the HTTP request is sent.

In this case, it's necessary to perform a graceful shutdown of the web server first, followed by a graceful shutdown of the Spring Stream. This ensures that the web server stops accepting requests while the streams have enough time to finish processing all pending requests. Therefore, the getPhase method must return a value smaller than Integer.MAX_VALUE - 2048, such as Integer.MAX_VALUE - 3000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants