spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

About ApplicationEvent and BootStrap

Open livk-cloud opened this issue 3 years ago • 1 comments

When I use "Spring Event Listener" to listen to the custom event "LivkEvent", use Spring.factories for autowiring, and introduce "org.springframework.cloud:spring-cloud-starter-bootstrap", my "Spring Event Listener" will Executed twice, I observed that the parent Application was generated when the event was published

image event-demo.zip

this my demo code I'm not sure if it's a bug or just by design If the design is like this, what is a good solution

livk-cloud avatar Jun 10 '22 06:06 livk-cloud

As discussed here https://github.com/spring-projects/spring-boot/issues/14656 I expect clean way to differentiate events coming from parent bootstrap context in listeners. In my case after adding kubernetes-config, my listeners receive events (earlier than i expect) from bootstrap context and I expect clean way to filter it.

norbson avatar Nov 12 '22 12:11 norbson