camel-component-controlbus
ControlBus component for rust-camel
Overview
The ControlBus component implements the ControlBus EIP pattern, allowing routes to manage other routes at runtime. It provides operations to start, stop, suspend, resume, and check the status of routes.
This is a producer-only component - it can only be used as a destination (to) in routes, not as a source (from).
Features
- Start, stop, suspend, resume routes
- Restart routes
- Query route status
- Dynamic route management from within routes
- Support for routeId from URI or header
Installation
Add to your Cargo.toml:
[]
= "0.2"
URI Format
controlbus:route?routeId=xxx&action=yyy
Actions
| Action | Description |
|---|---|
start |
Start a stopped route |
suspend |
Suspend a route (pause consumer intake, in-flight exchanges continue) |
resume |
Resume a suspended route (restart consumer intake) |
stop |
Stop a running route (full stop) |
restart |
Stop and start a route |
status |
Get route status (returned in body) |
Parameters
| Parameter | Required | Description |
|---|---|---|
action |
Yes | Action to perform |
routeId |
No* | Target route ID (*required unless using header) |
Usage
Static Route ID
use RouteBuilder;
use ControlBusComponent;
let mut ctx = new;
ctx.register_component;
// Start a route
let start_route = from
.to
.build?;
// Stop a route
let stop_route = from
.to
.build?;
Dynamic Route ID (from Header)
// Use CamelRouteId header for route ID
let route = from
.set_header
.to
.log
.build?;
Get Route Status
let route = from
.to
.process
.build?;
Suspend and Resume
// Suspend during maintenance
let suspend = from
.to
.build?;
// Resume after maintenance
let resume = from
.to
.build?;
Response Body
| Action | Body Content |
|---|---|
status |
Route status: "Started", "Stopped", "Suspended", "Starting", "Stopping", "Failed: " |
| Other actions | Empty |
Example: Scheduled Route Control
use RouteBuilder;
use ControlBusComponent;
use TimerComponent;
use CamelContext;
async
Error Handling
The component returns errors for:
- Unknown route ID
- Invalid action
- Missing routeId (when not in header)
let route = from
.error_handler
.to
.build?;
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the main repository for details.