Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ControlBus

The ControlBus component sends Route lifecycle commands through the RuntimeBus. It is a Producer-only Endpoint. It does not consume. It exposes no network API.

The controlbus-example uses a timer to suspend and resume a target route:

    let suspend_route = RouteBuilder::from("timer:suspend?delay=5000&repeatCount=1")
        .route_id("suspend-controller")
        .process(|exchange| async move {
            println!("[CONTROL] Suspending target-route...");
            Ok(exchange)
        })
        .to("controlbus:route?routeId=target-route&action=suspend&authorizedRoutes=target-route")
        .to("log:control?showBody=true")
        .build()?;
YAML equivalent
routes:
  - id: target-route
    from: "timer:target?period=500"
    steps:
      - to: "log:target?showBody=true"
  - id: suspend-controller
    from: "timer:suspend?delay=5000&repeatCount=1"
    steps:
      - to: "controlbus:route?routeId=target-route&action=suspend&authorizedRoutes=target-route"
      - to: "log:control?showBody=true"

The ControlBus URI declares the target routeId and the authorizedRoutes allowlist at config time. Exchange headers cannot set the target.

URI

controlbus:route?routeId=<id>&action=<action>&authorizedRoutes=<csv>
ParameterRequiredDescription
routeIdyesTarget Route ID. Must differ from the calling Route
actionyesLifecycle command. One of start, stop, suspend, resume, restart, or status
authorizedRoutesyesComma-separated allowlist. Endpoint fails closed when absent

Actions

ActionRuntime commandResponse body
startStartRouteempty
stopStopRouteempty
suspendSuspendRouteempty
resumeResumeRouteempty
restartReloadRouteempty
statusGetRouteStatusBody::Text with the lifecycle status string

restart performs an atomic Pipeline swap without drain semantics (ADR-0004). Suspend and resume support varies by component. status returns only the lifecycle string, not Route statistics.

Authorization

The Producer enforces three gates on every call (ADR-0034):

  1. The URI declares the target routeId.
  2. authorizedRoutes exists and contains that target.
  3. The target differs from the calling Route ID.

The CamelRouteId Exchange header cannot select or override the target. Exchange data is untrusted (ADR-0032). Only operator configuration drives the control plane. Authorization failures return CamelError::Unauthorized.

Errors

FailureResult
Missing or unauthorized targetCamelError::Unauthorized
Unknown action or unexpected status responseCamelError::ProcessorError
RuntimeHandle errorpasses through unchanged

The component declares no public enums. camel-api provides RouteAction, RuntimeCommand, and CamelError. Future variants use fallback match arms (ADR-0049).

Reference: ControlBus crate CONTEXT. Example source: examples/controlbus.