quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.65k stars 2.64k forks source link

Add Lifecycle onReady event #12935

Open speedfl opened 3 years ago

speedfl commented 3 years ago

Description Following logic on lifecycle documentation we can see that we have can register for startup and shuttdown events. It could be useful to have an event when the app is ready.

gsmet commented 3 years ago

/cc @mkouba

mkouba commented 3 years ago

We would need to define what "ready" means?

speedfl commented 3 years ago

You are right. Like for Angular. We should define life cycle. We could imagine:

I am thinking about other ideas 🤔

famod commented 3 years ago
mkouba commented 3 years ago

when All Applications coped Beans are Instantiated

@speedfl This is not valid in the context of CDI because @ApplicationScoped beans are instantiated lazily...

when application can receive traffic

That's a good point. However, it might make more sense to create a specific event for this, e.g. HttpServerStarted. @stuartwdouglas @gsmet WDYT? In theory, we could fire this event after this line, or?

all @Startup beans are done?

Well, and then we could introduce a new event that will be fired after all observers of this event are notified, etc. ;-).

In fact, you can specify a priority for your observer or a @Startup bean. Observers with smaller priority are called first. But the truth is that you can only be sure that your observer is notified before the ones with the default priority, which is 2500.

ia3andy commented 3 months ago

@mkouba any update on this, I think having an event when it's ready to receive request (health check ready when implemented)

mkouba commented 3 months ago

@mkouba any update on this, I think having an event when it's ready to receive request (health check ready when implemented)

That might be an interesting addition to the SR Health extension. WDYT @xstefank

xstefank commented 3 months ago

Sure, on top of my head, this should be doable. I'll look.