Skip to content

spring cloud stream destroys The readyness state #2083

Open
@GreenRover

Description

@GreenRover

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:

  1. Download: readiness.zip
  2. If you dont like the solace binder replace against what ever you want.
  3. Run the spring application
  4. Wait for "BusinessLogic: load my cache from DB" in log
  5. Open on browser: http://localhost:9007/actuator/health/readinessState
    Expected: status: "OUT_OF_SERVICE"
    Current state: status: "OK"
  6. Wait for "BusinessLogic: cache load complete" in log
    Expected: status: "OK"
    Current state: status: "OK"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions