spring-cloud / spring-cloud/spring-cloud-stream

spring cloud stream destroys The readyness state

Open
#2,083 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
646
Avg merge
2d 3h
Merged PRs (30d)
8

Description

Describe the issue
Originally invented @philwebb with: https://github.com/spring-projects/spring-boot/issues/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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with InputBindingLifecycle.java and DefaultBinderFactory.java around line 325, then trace SpringApplication.run through callRunners and listeners.running. Reproduce the issue with readiness.zip and check the /actuator/health/readinessState endpoint while the cache loads. Done means readiness stays OUT_OF_SERVICE until the application cache-loading runner completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.