KioMQ provides the core building blocks to run background work inside your Tokio services:
- A Queue to enqueue tasks/jobs.
- One or more Workers to process jobs concurrently.
- Pluggable Stores:
InMemoryStore(ephemeral),RedisStore(durable, distributed), RocksDB (under construction). - Scheduling – delays, cron expressions, repeat policies.
- Reliability – retries, backoff strategies, stalled-job detection.
- Observability – events, progress updates, per-worker metrics.
Inspired by BullMQ's ergonomics, implemented as an embeddable Rust library.
Contents: Key features · Tokio runtime · Installation · Quick-start · Panics & errors · Configuration · Events & observability · Progress updates · Backends · Benchmarks · Testing · License
Key features
- Async & sync processors – async for I/O-bound work, sync (
spawn_blocking) for CPU-bound. - Configurable concurrency – defaults to CPU count.
- Event-driven idle workers – near-zero CPU when empty, using lock-free atomics and
tokio::sync::Notify. - Bulk enqueue –
Queue::bulk_add/Queue::bulk_add_only. - Priority & delayed jobs – by score or after N ms / cron schedule.
- Repeat policies – cron, backoff-driven, fixed interval, immediate.
Tokio runtime requirements
Multi-thread runtime is recommended:
= { = "1", = ["rt-multi-thread", "macros"] }
For tests:
async
Installation
[]
= "0.1"
Cargo features: redis-store (default), rocksdb-store, tracing.
Quick-start
Async worker
use Arc;
use ;
async
Sync worker
Sync processors run on a blocking thread via tokio::task::spawn_blocking — suitable for
heavy computation, hashing, blocking FFI, etc.
use Arc;
use ;
async
Panics & errors in the processor
A processor signals a job failure by returning Err. The worker catches the error,
marks the job as failed, and — depending on the attempts configuration — retries it
with the configured backoff.
Panics inside a processor are also caught by the worker and treated as failures, so a rogue job cannot bring down the whole process.
Async backtrace with #[framed]
Annotate your processor with #[framed] (re-exported from
async_backtrace as kiomq::framed) for richer async
stack traces:
use Arc;
use ;
async
async
Configuration
Queue options (QueueOpts)
use ;
let queue_opts = QueueOpts ;
Per-job options (JobOptions)
use JobOptions;
let opts = JobOptions ;
Worker options (WorkerOpts)
use WorkerOpts;
let opts = WorkerOpts ;
Events & observability
Subscribe to job-state events on the queue:
use ;
// Subscribe to a specific state.
let _listener_id = queue.on;
// Subscribe to all events.
let _listener_id2 = queue.on_all_events;
// Remove a listener when no longer needed.
queue.remove_event_listener;
Progress updates
Report progress from inside your processor using job.update_progress:
use Arc;
use ;
async
Backends
In-memory
InMemoryStore – ideal for tests, dev, and short-lived tasks. No external dependencies.
Redis (default feature)
Durable, distributed workloads. Requires a running Redis instance:
RocksDB (under construction)
Embedded persistence – work in progress.
Benchmarks
Testing
License
MIT — see LICENSE