public interface StartupListener
CamelContext
has almost done all work when starting.
This can be used to perform any custom work when the entire CamelContext
has been initialized and almost
started. For example this ensures that all Camel routes have been started and are up and running, before this callback
is invoked.
The state of CamelContext
may still be in starting when this callback is invoked, this is by design.
The callback is invoked during the routes startup procedure when starting CamelContext
.
For example the QuartzComponent leverages this to ensure the Quartz scheduler does not start until after all the
Camel routes and services have already been started.
Important: You cannot use this listener to add and start new routes to the CamelContext
as this is not
supported by design, as this listener plays a role during starting up routes. Instead you can use an EventNotifier
and listen on the CamelContextStartedEvent
event and then add and start new routes from there.
Instead use the ExtendedStartupListener
if you wish to add new routes.ExtendedStartupListener
Modifier and Type | Method and Description |
---|---|
void |
onCamelContextStarted(CamelContext context,
boolean alreadyStarted)
Callback invoked when the
CamelContext is about to be fully started (not started yet). |
void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception
CamelContext
is about to be fully started (not started yet).
Yes we are aware of the method name, but we can all have a bad-naming day.context
- the Camel contextalreadyStarted
- whether or not the CamelContext
already has been started. For example the context
could already have been started, and then a service is added/started later which still
triggers this callback to be invoked.Exception
- can be thrown in case of errors to fail the startup process and have the application
fail on startup.Apache Camel