camel-component-seda
SEDA component for rust-camel (asynchronous in-memory staging)
Overview
The SEDA (Staged Event-Driven Architecture) component provides asynchronous, in-memory communication between routes via bounded queues. Unlike the Direct component (synchronous), a producer sends to a SEDA endpoint and returns immediately — the consumer processes the exchange asynchronously from a background task.
This is ideal for decoupling routes, buffering bursts of messages, and building staged processing pipelines.
Features
- Asynchronous: Producer returns immediately; consumer processes in background
- Bounded queues: Configurable queue size with fail-fast or blocking behavior
- Exchange patterns: InOnly (fire-and-forget) and InOut (request-reply with timeout)
- Fanout: Multiple consumers on the same SEDA name (pub-sub)
- Configurable concurrency:
concurrentConsumershint for parallel processing
Installation
Add to your Cargo.toml:
[]
= "*"
URI Format
seda:name[?options]
Options
| Option | Default | Description |
|---|---|---|
size |
1000 |
Queue capacity |
exchangePattern |
InOnly |
InOnly or InOut |
multipleConsumers |
false |
Enable fanout (multiple consumers) |
concurrentConsumers |
1 |
Concurrency hint for the runtime |
blockWhenFull |
false |
Block producer if queue is full |
timeout |
30000 |
Timeout (ms) for InOut and blockWhenFull |
waitForTaskToComplete |
IfReplyExpected |
Never, IfReplyExpected, or Always |
discardIfNoConsumers |
false |
Silently discard if no active consumers |
Usage
Connecting Routes (Fire-and-Forget)
use RouteBuilder;
use SedaComponent;
use CamelContext;
let mut ctx = new;
ctx.register_component;
// Route 1: Producer (returns immediately)
let route1 = from
.to
.build?;
// Route 2: Consumer (processes asynchronously)
let route2 = from
.to
.build?;
ctx.add_route.await?;
ctx.add_route.await?;
Request-Reply (InOut)
// Consumer processes and replies
let consumer = from
.process
.build?;
// Producer waits for reply (up to timeout)
let producer = from
.to
.to
.build?;
Fanout (Multiple Consumers)
// Enable multipleConsumers — all subscribers receive each exchange
let publisher = from
.to
.build?;
let subscriber_a = from
.to
.build?;
let subscriber_b = from
.to
.build?;
Backpressure with blockWhenFull
// Producer blocks (up to timeout) when queue is full
let route = from
.to
.build?;
Differences from Direct
| Direct | SEDA | |
|---|---|---|
| Communication | Synchronous | Asynchronous |
| Producer blocks? | Yes (until consumer done) | No (unless blockWhenFull) |
| Queue | None | Bounded (size) |
| Multiple consumers | No | Yes (multipleConsumers) |
| Use case | Modular route linking | Decoupling, buffering, staging |
Example
See examples/seda-demo/ for a complete working example.
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the main repository for details.