Interface ManagementStrategy

All Superinterfaces:
AutoCloseable, Service, StaticService

public interface ManagementStrategy extends StaticService
Top-level SPI for Camel's management and observability layer, coordinating JMX registration, lifecycle events, and statistics collection across all Camel artifacts.

When the camel-management JAR is on the classpath, JmxManagementStrategy is activated and delegates MBean registration to a ManagementAgent. Without that JAR, DefaultManagementStrategy is used, which still dispatches lifecycle events to registered EventNotifiers but does not expose JMX MBeans.

The strategy is the central hub for two concerns: management objects (registering and unregistering Camel components, routes, processors, etc. as MBeans via ManagementObjectStrategy and ManagementObjectNameStrategy) and events (delivering CamelEvent notifications to all registered EventNotifiers via notify(CamelEvent)). A third-party management backend can be plugged in by implementing this interface and providing a ManagementStrategyFactory.

See JMX in the Camel user manual.

See Also:
  • Method Details

    • manageObject

      void manageObject(Object managedObject) throws Exception
      Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.
      Parameters:
      managedObject - the managed object
      Throws:
      Exception - can be thrown if the object could not be added
    • unmanageObject

      void unmanageObject(Object managedObject) throws Exception
      Removes the managed object.
      Parameters:
      managedObject - the managed object
      Throws:
      Exception - can be thrown if the object could not be removed
    • isManaged

      boolean isManaged(Object managedObject)
      Determines if an object or name is managed.
      Parameters:
      managedObject - the object to consider
      Returns:
      true if the given object is managed
    • isManagedName

      boolean isManagedName(Object name)
      Determines if an object or name is managed.
      Parameters:
      name - the name to consider
      Returns:
      true if the given name is managed
    • notify

      void notify(CamelEvent event) throws Exception
      Management events provide a single model for capturing information about execution points in the application code. Management strategy implementations decide if and where to record these events. Applications communicate events to management strategy implementations via the notify(EventObject) method.
      Parameters:
      event - the event
      Throws:
      Exception - can be thrown if the notification failed
    • getEventNotifiers

      List<EventNotifier> getEventNotifiers()
      Gets the event notifiers.
      Returns:
      event notifiers
    • getStartedEventNotifiers

      List<EventNotifier> getStartedEventNotifiers()
      Gets all the started event notifiers, which is ready to be used.
      Returns:
      started event notifiers
    • addEventNotifier

      void addEventNotifier(EventNotifier eventNotifier)
      Adds the event notifier to use.

      Ensure the event notifier has been started if its a Service, as otherwise it would not be used.

      Parameters:
      eventNotifier - event notifier
    • removeEventNotifier

      boolean removeEventNotifier(EventNotifier eventNotifier)
      Removes the event notifier
      Parameters:
      eventNotifier - event notifier to remove
      Returns:
      true if removed, false if already removed
    • getEventFactory

      EventFactory getEventFactory()
      Gets the event factory
      Returns:
      event factory
    • setEventFactory

      void setEventFactory(EventFactory eventFactory)
      Sets the event factory to use
      Parameters:
      eventFactory - event factory
    • getManagementObjectNameStrategy

      ManagementObjectNameStrategy getManagementObjectNameStrategy()
      Gets the naming strategy to use
      Returns:
      naming strategy
    • setManagementObjectNameStrategy

      void setManagementObjectNameStrategy(ManagementObjectNameStrategy strategy)
      Sets the naming strategy to use
      Parameters:
      strategy - naming strategy
    • getManagementObjectStrategy

      ManagementObjectStrategy getManagementObjectStrategy()
      Gets the object strategy to use
      Returns:
      object strategy
    • setManagementObjectStrategy

      void setManagementObjectStrategy(ManagementObjectStrategy strategy)
      Sets the object strategy to use
      Parameters:
      strategy - object strategy
    • getManagementAgent

      ManagementAgent getManagementAgent()
      Gets the management agent
      Returns:
      management agent
    • setManagementAgent

      void setManagementAgent(ManagementAgent managementAgent)
      Sets the management agent to use
      Parameters:
      managementAgent - management agent
    • manageProcessor

      boolean manageProcessor(NamedNode definition)
      Filter whether the processor should be managed or not.

      Is used to filter out unwanted processors to avoid managing at too fine grained level.

      Parameters:
      definition - definition of the processor
      Returns:
      true to manage it