-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Document how to perform tasks after application startup #22100
Comments
This expected behavior and a combination of two things. First, the new liveness and readiness support implies new application events. The event changing the readiness state once the app has started is fired after the event you’re relying on: https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-application-events-and-listeners Now that event is never fired and the readiness state never changes as you’re locking the event publishing thread with the processing. It’s generally bad practice to process long running tasks while handling an application event. You should in most cases kick off that processing in a worker thread/executor. In this very case, Spring Boot is providing an ApplicationRunner interface you can implement. Such components will be called at startup (and can be ordered). This allows you to keep the application lifecycle consistent with what you’re trying to achieve. See https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-kubernetes-probes-lifecycle Let us know if updating your application with such a change has the expected result. Thanks! |
Ok, you are right it is not a bug it is a feature. |
No worries! I'm turning this issue into a documentation improvement. Thanks! |
Description
I have a service MyServiceImpl that listen to the ApplicationReadyEvent
In the method doStuff I run a while(true) - run forever
(In the original app I run a (infinite) sink that is getting data from a rest endpoint and publish it to kafka)
In spring boot 2.3.1 the actuator endpoint status for readiness is OUT_OF_SERVICE because the listener doesn't finish
In spring boot 2.2.8 the actuator endpoint status for readiness is UP
spring-boot or spring-actuator problem
git example
Start the app with spring boot 2.3.1
mvn spring-but:run
-access the endpoint for readiness
http://localhost:8080/.mystatus/ready
-The health is "status": "OUT_OF_SERVICE"
Start the app with spring boot 2.2.8
mvn spring-but:run
access the endpoint for readiness
http://localhost:8080/.mystatus/ready
The health is "status": "UP"
The text was updated successfully, but these errors were encountered: