camel-component-direct
Direct component for rust-camel (in-memory routing)
Overview
The Direct component provides synchronous, in-memory communication between routes. When a producer sends to a direct endpoint, it blocks until the consumer's route has finished processing the exchange.
This is ideal for connecting routes within the same Camel context and for building modular integration flows.
Features
- Synchronous: Producer waits for consumer processing to complete
- In-memory: No network overhead, direct method calls
- Request-Reply: Returns the (possibly transformed) exchange
- Dynamic: Routes can be connected/disconnected at runtime
Installation
Add to your Cargo.toml:
[]
= "0.2"
URI Format
direct:name
Usage
Connecting Routes
use RouteBuilder;
use DirectComponent;
use CamelContext;
let mut ctx = new;
ctx.register_component;
// Route 1: Producer
let route1 = from
.to
.build?;
// Route 2: Consumer
let route2 = from
.process
.to
.build?;
ctx.add_route.await?;
ctx.add_route.await?;
Request-Reply Pattern
// Send request and receive response
let route = from
.process
.build?;
// In another route
let client_route = from
.set_body
.to // Blocks until response
.log
.build?;
Multiple Producers, One Consumer
// Multiple sources send to same processing route
let route_a = from
.set_header
.to
.build?;
let route_b = from
.set_header
.to
.build?;
let processor = from
.log
.to
.build?;
Error Propagation
Errors from the consumer route are propagated back to the producer:
let consumer = from
.process
.build?;
let producer = from
.to // Will receive error
.build?;
Example: Modular Routes
use RouteBuilder;
use DirectComponent;
use CamelContext;
async
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the main repository for details.