Skip to content

Document how to perform tasks after application startup #22100

@laurentiu-miu

Description

@laurentiu-miu

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

  1. 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"

  2. 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"

public class MyServiceImpl {
  @EventListener(ApplicationReadyEvent.class)
  public void doStuff(){
    int count = 0;
    while(true){
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      System.out.println(count++);
    }
  }
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions