Interface RoutePolicy


public interface RoutePolicy
Per-route lifecycle hook that receives callbacks at each state change and at the beginning and end of every Exchange, enabling dynamic control of route behaviour at runtime.

A RoutePolicy can suspend or resume a route's consumer in response to external conditions, implement throttling by counting inflight exchanges (as

invalid reference
org.apache.camel.throttling.ThrottlingInflightRoutePolicy
does), enforce time-window scheduling, or perform custom instrumentation. Policies are attached to a route via the DSL .routePolicy() call or globally via a RoutePolicyFactory registered on the context.

See the Route Policy documentation for usage patterns and built-in implementations.

See Also:
  • Method Details

    • onInit

      void onInit(Route route)
      Callback invoked when the Route is being initialized
      Parameters:
      route - the route being initialized
    • onRemove

      void onRemove(Route route)
      Callback invoked when the Route is being removed from CamelContext
      Parameters:
      route - the route being removed
    • onStart

      void onStart(Route route)
      Callback invoked when the Route is being started
      Parameters:
      route - the route being started
    • onStop

      void onStop(Route route)
      Callback invoked when the Route is being stopped
      Parameters:
      route - the route being stopped
    • onSuspend

      void onSuspend(Route route)
      Callback invoked when the Route is being suspended
      Parameters:
      route - the route being suspended
    • onResume

      void onResume(Route route)
      Callback invoked when the Route is being resumed
      Parameters:
      route - the route being resumed
    • onExchangeBegin

      void onExchangeBegin(Route route, Exchange exchange)
      Callback invoked when an Exchange is started being routed on the given Route
      Parameters:
      route - the route where the exchange started from
      exchange - the created exchange
    • onExchangeDone

      void onExchangeDone(Route route, Exchange exchange)
      Callback invoked when an Exchange is done being routed, where it started from the given Route

      Notice this callback is invoked when the Exchange is done and the Route is the route where the Exchange was started. Most often its also the route where the exchange is done. However, it's possible to route an Exchange to other routes using endpoints such as direct or seda. Bottom line is that the Route parameter may not be the endpoint route and thus why we state it's the starting route.

      Parameters:
      route - the route where the exchange started from
      exchange - the created exchange