camel-component-timer
Timer component for rust-camel
Overview
The Timer component produces exchanges at periodic intervals. It's useful for scheduling tasks, generating periodic events, and triggering routes on a time-based schedule.
This is a consumer-only component - it can only be used as a source (from) in routes, not as a destination (to).
Features
- Periodic tick generation
- Configurable initial delay
- Limited or unlimited repetition
- Cancellation support
- Header metadata (name, counter)
Installation
Add to your Cargo.toml:
[]
= "0.2"
URI Format
timer:name[?options]
URI Options
| Option | Default | Description |
|---|---|---|
period |
1000 |
Interval between ticks in milliseconds |
delay |
0 |
Initial delay before first tick in milliseconds |
repeatCount |
unlimited | Maximum number of ticks |
Usage
Basic Timer
use RouteBuilder;
use TimerComponent;
use CamelContext;
let mut ctx = new;
ctx.register_component;
// Fire every second
let route = from
.log
.to
.build?;
With Initial Delay
// Wait 5 seconds, then fire every 10 seconds
let route = from
.to
.build?;
Limited Repetition
// Fire exactly 3 times
let route = from
.to
.build?;
Exchange Headers
The timer sets the following headers on each exchange:
| Header | Type | Description |
|---|---|---|
CamelTimerName |
String | Timer name from URI |
CamelTimerCounter |
Number | Tick counter (1, 2, 3...) |
Example: Scheduled Task
use RouteBuilder;
use TimerComponent;
use LogComponent;
use CamelContext;
async
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the main repository for details.