camel-core
Core routing engine for rust-camel
Overview
camel-core is the heart of the rust-camel framework. It provides the CamelContext for managing routes, the Registry for component registration, and the core route execution engine. This crate orchestrates all the other components to enable message routing.
This is the main crate you'll use when building a rust-camel application. It brings together components, processors, and routes into a cohesive integration framework.
Features
- CamelContext: Central context for managing routes and components
- Registry: Component registry for endpoint resolution
- Route: Route definitions and lifecycle management
- RouteController: Start, stop, suspend, and resume routes
- Pipeline composition: Tower-based middleware composition
- Hot-reload: Live route updates with ArcSwap (no downtime)
- Supervision: Auto-recovery with configurable exponential backoff
- Tracer Integration: Automatic message flow tracing support
- Bean Integration: BeanRegistry support for YAML DSL bean step resolution
Installation
Add to your Cargo.toml:
[]
= "0.2"
Usage
Creating a Camel Context
use CamelContext;
use RouteBuilder;
async
Route Lifecycle Management
// Start a specific route
ctx.start_route.await?;
// Suspend a route (pauses consumer intake, allows in-flight exchanges to complete)
ctx.suspend_route.await?;
// Resume a suspended route (restarts consumer intake)
ctx.resume_route.await?;
// Stop a route
ctx.stop_route.await?;
// Check route status
let status = ctx.route_status;
Core Types
| Type | Description |
|---|---|
CamelContext |
Main context for route management |
Registry |
Component and endpoint registry |
Route |
A configured route |
RouteDefinition |
Route builder output |
RouteController |
Lifecycle management trait |
SupervisingRouteController |
Auto-recovery with exponential backoff for crashed consumers |
DefaultRouteController |
Default implementation with optional BeanRegistry (with_beans()) |
Architecture
┌─────────────────────────────────────┐
│ CamelContext │
│ ┌─────────────────────────────┐ │
│ │ Registry │ │
│ │ ┌───────┐ ┌───────┐ │ │
│ │ │Timer │ │ Log │ ... │ │
│ │ │Comp │ │ Comp │ │ │
│ │ └───────┘ └───────┘ │ │
│ └─────────────────────────────┘ │
│ ┌─────────────────────────────┐ │
│ │ Routes │ │
│ │ Route 1 │ Route 2 │ ...│ │
│ └─────────────────────────────┘ │
└─────────────────────────────────────┘
Advanced Features
SupervisingRouteController
Wraps any route controller with automatic recovery using configurable exponential backoff. When a consumer crashes, it automatically restarts after a delay that increases with each failure.
Hot-reload System
Live route updates without service restart using ArcSwap and ReloadCoordinator. Update route definitions at runtime with zero downtime.
ControlBus Integration
Dynamic route lifecycle management via the control bus pattern. Start, stop, suspend, and resume routes programmatically.
Bean Integration
Use DefaultRouteController::with_beans() to enable bean step resolution in YAML DSL routes:
use DefaultRouteController;
use BeanRegistry;
let mut bean_registry = new;
bean_registry.register;
let controller = with_beans;
// Pass controller to CamelContext::with_controller()
See examples/bean-demo for a complete example.
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the main repository for details.