Interface LifecycleStrategy

All Known Subinterfaces:
AutowiredLifecycleStrategy

public interface LifecycleStrategy
Observer SPI that receives callbacks for every significant lifecycle event in a CamelContext.

Callbacks cover the full lifecycle of the context itself (initializing, starting, started, stopping, stopped), plus every Component, Endpoint, Route, and Service that is added, started, stopped, or removed. Thread pool creation and shutdown are also notified. Multiple strategies can be registered via CamelContext.addLifecycleStrategy(LifecycleStrategy). The JMX management layer (ManagementStrategy) is the primary built-in implementor; it registers and unregisters MBeans in response to lifecycle events. Implementations may throw VetoCamelContextStartException from onContextInitializing(CamelContext) to prevent context startup.

See Lifecycle in the Camel user manual.

See Also:
  • Method Details

    • onContextInitializing

      default void onContextInitializing(CamelContext context) throws VetoCamelContextStartException
      Notification on initializing a CamelContext.
      Parameters:
      context - the camel context
      Throws:
      VetoCamelContextStartException - can be thrown to veto starting CamelContext. Any other runtime exceptions will be logged at WARN level by Camel will continue starting itself.
    • onContextInitialized

      default void onContextInitialized(CamelContext context) throws VetoCamelContextStartException
      Notification on initialized CamelContext.
      Parameters:
      context - the camel context
      Throws:
      VetoCamelContextStartException - can be thrown to veto starting CamelContext. Any other runtime exceptions will be logged at WARN level by Camel will continue starting itself.
    • onContextStarting

      default void onContextStarting(CamelContext context) throws VetoCamelContextStartException
      Notification on starting a CamelContext.
      Parameters:
      context - the camel context
      Throws:
      VetoCamelContextStartException - can be thrown to veto starting CamelContext. Any other runtime exceptions will be logged at WARN level by Camel will continue starting itself.
    • onContextStarted

      default void onContextStarted(CamelContext context)
      Notification on started CamelContext.
      Parameters:
      context - the camel context
    • onContextStopping

      default void onContextStopping(CamelContext context)
      Notification on stopping a CamelContext.
      Parameters:
      context - the camel context
    • onContextStopped

      default void onContextStopped(CamelContext context)
      Notification on stopped CamelContext.
      Parameters:
      context - the camel context
    • onComponentAdd

      void onComponentAdd(String name, Component component)
      Notification on adding an Component.
      Parameters:
      name - the unique name of this component
      component - the added component
    • onComponentRemove

      void onComponentRemove(String name, Component component)
      Notification on removing an Component.
      Parameters:
      name - the unique name of this component
      component - the removed component
    • onEndpointAdd

      void onEndpointAdd(Endpoint endpoint)
      Notification on adding an Endpoint.
      Parameters:
      endpoint - the added endpoint
    • onEndpointRemove

      void onEndpointRemove(Endpoint endpoint)
      Notification on removing an Endpoint.
      Parameters:
      endpoint - the removed endpoint
    • onDataFormatCreated

      default void onDataFormatCreated(String name, DataFormat dataFormat)
      Notification on DataFormat being resolved from the Registry
      Parameters:
      name - the unique name of the DataFormat
      dataFormat - the resolved DataFormat
    • onLanguageCreated

      default void onLanguageCreated(String name, Language language)
      Notification on a Language instance being resolved.
      Parameters:
      name - the unique name of the Language
      language - the created Language
    • onServiceAdd

      void onServiceAdd(CamelContext context, Service service, @Nullable Route route)
      Notification on adding a Service.
      Parameters:
      context - the camel context
      service - the added service
      route - the route the service belongs to if any possible to determine
    • onServiceRemove

      void onServiceRemove(CamelContext context, Service service, @Nullable Route route)
      Notification on removing a Service.
      Parameters:
      context - the camel context
      service - the removed service
      route - the route the service belongs to if any possible to determine
    • onServiceRemove

      default void onServiceRemove(CamelContext context, Service service, @Nullable Route route, boolean shutdown)
      Notification on removing a Service.
      Parameters:
      context - the camel context
      service - the removed service
      route - the route the service belongs to if any possible to determine
      shutdown - whether camel is being shutdown
    • onRoutesAdd

      void onRoutesAdd(Collection<Route> routes)
      Notification on adding Route(s).
      Parameters:
      routes - the added routes
    • onRoutesRemove

      void onRoutesRemove(Collection<Route> routes)
      Notification on removing Route(s).
      Parameters:
      routes - the removed routes
    • onRouteContextCreate

      void onRouteContextCreate(Route route)
      Notification on creating Route(s).
      Parameters:
      route - the created route context
    • onThreadPoolAdd

      void onThreadPoolAdd(CamelContext camelContext, ThreadPoolExecutor threadPool, String id, @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId)
      Notification on adding a thread pool.
      Parameters:
      camelContext - the camel context
      threadPool - the thread pool
      id - id of the thread pool
      sourceId - id of the source creating the thread pool (can be null in special cases)
      routeId - id of the route for the source (is null if no source)
      threadPoolProfileId - id of the thread pool profile, if used for creating this thread pool (can be null)
    • onThreadPoolRemove

      void onThreadPoolRemove(CamelContext camelContext, ThreadPoolExecutor threadPool)
      Notification on removing a thread pool.
      Parameters:
      camelContext - the camel context
      threadPool - the thread pool
    • onThreadPoolAdd

      default void onThreadPoolAdd(CamelContext camelContext, ExecutorService executorService, String id, @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId)
      Notification on adding an executor service (such as a virtual thread executor) that is not a ThreadPoolExecutor.
      Parameters:
      camelContext - the camel context
      executorService - the executor service
      id - id of the thread pool
      sourceId - id of the source creating the thread pool (can be null in special cases)
      routeId - id of the route for the source (is null if no source)
      threadPoolProfileId - id of the thread pool profile, if used for creating this thread pool (can be null)
    • onThreadPoolRemove

      default void onThreadPoolRemove(CamelContext camelContext, ExecutorService executorService)
      Notification on removing an executor service (such as a virtual thread executor) that is not a ThreadPoolExecutor.
      Parameters:
      camelContext - the camel context
      executorService - the executor service