rust-rabbit π°
A simple, reliable RabbitMQ client library for Rust. Easy to use with minimal configuration and flexible retry mechanisms.
π Key Features
- Simple API: Just
PublisherandConsumerwith essential methods - Flexible Retry: Exponential, linear, or custom retry mechanisms
- Auto-Setup: Automatic queue/exchange declaration and binding
- Built-in Reliability: Default ACK behavior with intelligent error handling
- Zero Complexity: No enterprise patterns, no metrics - just core messaging
π¦ Quick Start
Add to your Cargo.toml:
[]
= "1.0"
= { = "1.0", = ["full"] }
= { = "1.0", = ["derive"] }
π― Basic Usage
Publisher - Send Messages
use ;
use Serialize;
async
Consumer - Receive Messages with Retry
use ;
use Deserialize;
async
π Retry Configurations
Built-in Retry Patterns
use RetryConfig;
use Duration;
// Exponential: 1s β 2s β 4s β 8s β 16s (5 retries)
let exponential = exponential_default;
// Custom exponential: 2s β 4s β 8s β 16s β 32s (max 60s)
let custom_exp = exponential;
// Linear: 10s β 10s β 10s (3 retries)
let linear = linear;
// Custom delays: 1s β 5s β 30s
let custom = custom;
// No retries - fail immediately
let no_retry = no_retry;
How Retry Works
// Failed messages are automatically:
// 1. Sent to retry queue with delay (e.g., orders.retry.1)
// 2. After delay, returned to original queue for retry
// 3. If max retries exceeded, sent to dead letter queue (e.g., orders.dlq)
βοΈ Advanced Features
MessageEnvelope System
For advanced retry tracking and error handling, use the MessageEnvelope system:
use ;
use ;
async
Connection Options
use Connection;
// Simple connection
let connection = new.await?;
// Different connection URLs
let local = new.await?;
let remote = new.await?;
let secure = new.await?;
Publisher Options
use PublishOptions;
let options = new
.mandatory // Make delivery mandatory
.priority; // Message priority (0-255)
publisher.publish_to_queue.await?;
Consumer Options
let consumer = builder
.with_retry
.bind_to_exchange // Exchange binding with routing key
.concurrency // Process 10 messages in parallel
.build;
π Documentation
For detailed guides and advanced topics:
- Retry Configuration Guide - Detailed retry patterns and configuration
- Exchange & Queue Management - Queue binding, exchange types, and best practices
- Error Handling - Error types and handling strategies
- Best Practices - Production tips and patterns
π οΈ Examples
See the examples/ directory for complete working examples:
- Basic Publisher - Simple message publishing
- Basic Consumer - Simple message consumption
- Retry Examples - Different retry configurations
- Production Setup - Production-ready configuration
π§ͺ Testing
Run the tests:
For integration tests with real RabbitMQ:
# Start RabbitMQ with Docker
# Run integration tests
π§ Requirements
- Rust: 1.70+
- RabbitMQ: 3.8+
- Tokio: Async runtime
π¦ Migration from v0.x
If you're upgrading from the complex v0.x version:
// OLD (v0.x) - Complex
let consumer = new.await?;
// NEW (v1.0) - Simple
let consumer = builder
.with_retry
.concurrency
.build;
Major Changes:
- β
Simplified API with just
PublisherandConsumer - β Removed enterprise patterns (saga, event sourcing, request-response)
- β Removed metrics and health monitoring
- β Unified retry system with flexible mechanisms
- β Auto-declare queues and exchanges by default
π― Design Philosophy
rust-rabbit v1.0 follows these principles:
- Simplicity First: Only essential features, no bloat
- Reliability Built-in: Automatic retry and error handling
- Easy Configuration: Sensible defaults, minimal setup
- Production Ready: Persistent messages, proper ACK handling
- Developer Friendly: Clear errors, good documentation
πΊοΈ Roadmap
See ROADMAP.md for planned features:
- Connection pooling and load balancing
- Monitoring and metrics integration
- Advanced retry patterns and policies
- Performance optimizations
- Additional messaging patterns
π License
MIT License - see LICENSE for details.
π€ Contributing
Contributions welcome! Please read our contributing guide and submit pull requests.
π¬ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs.rs
Made with β€οΈ by the rust-rabbit team