Description
Describe the issue
Originally invented @philwebb with: spring-projects/spring-boot#7656
The "readiness" framework, that enables to register "ApplicationRunner" to ensure for example a "cache" is loaded before the application is ready to server.
But when spring cloud stream is used following happend:
@org.springframework.boot.SpringApplication#run(java.lang.String...)
refreshContext(context);
--> ScSt wants to create the binder
--> DefaultBinderFactory starts a new inner SpringApplication
--> It run again: SpringApplication#run(java.lang.String...)
--> callRunners(context, applicationArguments); // will not find any "ApplicationRunner", what is correct
--> listeners.running(context); // called and fire the "ReadinessState.ACCEPT". This is the BUG
--> .... spring cloud stream set up its binders ...
callRunners(context, applicationArguments); // will execute the "ApplicationRunner" that is set up my application cache.
listeners.running(context); // The "ReadinessState.ACCEPT" event gets fired that i expect.
To Reproduce
Steps to reproduce the behavior:
- Download: readiness.zip
- If you dont like the solace binder replace against what ever you want.
- Run the spring application
- Wait for "BusinessLogic: load my cache from DB" in log
- Open on browser: http://localhost:9007/actuator/health/readinessState
Expected: status: "OUT_OF_SERVICE"
Current state: status: "OK" - Wait for "BusinessLogic: cache load complete" in log
Expected: status: "OK"
Current state: status: "OK"