This project is a Rust-based clone of an original Python implementation, designed to explore asynchronous programming patterns in Rust while improving upon the original architecture. During development, several hidden bugs in the original design were uncovered and resolved, leading to enhanced logic and performance.
π― Project Goals:
- Learn and implement async Rust patterns
 - Improve upon existing Python architecture
 - Eventually replace Python implementation with Rust
 - Build a robust, production-ready RabbitMQ client
 
Note: Currently awaiting Lapin bug fixes for channel reconnection handling. Project updates will follow as dependencies evolve.
- β‘ Full Tokio Runtime - Leveraging async/await for maximum performance
 - π Lapin AMQP Client - Robust RabbitMQ integration (with pending bug fixes)
 - ποΈ SQLx with PostgreSQL - Type-safe database operations
 - π Producer/Consumer Patterns - Reliable message processing
 - π§ Configurable Architecture - Flexible and extensible design
 - π High Performance - Built with Rust's zero-cost abstractions
 
rabbitmq-async-example/
βββ π src/
β   βββ π bin/
β   β   βββ main.rs              # Application entry point
β   βββ π database/
β   β   βββ π models/           # Database models and schemas
β   β   βββ π functions/        # Database operations
β   βββ π mapping/              # Data mapping and validation
β   βββ π rmq/                  # RabbitMQ handlers and schemas
β   βββ π tasks/
β   β   βββ π producer/         # Message producers
β   β   βββ π consumer/         # Message consumers
β   βββ configs.rs               # Configuration management
β   βββ errors.rs                # Error handling
β   βββ lib.rs                   # Library exports
βββ π .github/workflows/        # CI/CD pipelines
βββ π migrations/               # SQLX migrations
βββ Cargo.toml                   # Rust dependencies
βββ rustfmt.toml                 # Code formatting
βββ docker_compose.yml           # Docker images examples for project
βββ LICENSE                      # MIT LicenseProject Architecture Overview
| Module | Purpose | Key Files | 
|---|---|---|
src/rmq/ | 
RabbitMQ connection management and message handling | handlers.rs, schemas.rs | 
src/tasks/ | 
Producer and consumer implementations | producer/methods.rs, consumer/methods.rs | 
src/database/ | 
PostgreSQL operations with SQLx | models/, functions/mod.rs | 
src/mapping/ | 
Data validation and transformation | schemas.rs, validators.rs | 
src/configs/ | 
Application configuration management | configs.rs | 
src/errors/ | 
Custom error handling | errors.rs | 
π Source Code Details
src/bin/main.rs- Application entry point and startup logicsrc/lib.rs- Library exports and module declarationssrc/configs.rs- Configuration struct and environment setupsrc/errors.rs- Custom error types and error handling
src/rmq/schemas.rs- Message schemas and data structures for RabbitMQsrc/rmq/handlers.rs- Connection handling and message processing logic
src/tasks/producer/methods.rs- All methods for producing messages to RabbitMQsrc/tasks/consumer/methods.rs- Consumer logic and message processing methodssrc/tasks/consumer/utils.rs- Utility functions to simplify consumer logic
src/database/models/- Database models and entity definitions:application_requests.rs- Request modelsapplication_responses.rs- Client response modelsservice_responses.rs- Service response modelsservices.rs- Main service modelsfail_table.rs- Error and failure tracking models
src/database/functions/mod.rs- Database operations and queries
src/mapping/schemas.rs- Data transformation schemassrc/mapping/validators.rs- Input validation and data sanitization
Cargo.toml- Rust dependencies and project metadatarustfmt.toml- Code formatting configuration.env.example- Environment variables template.github/workflows/project_check.yaml- CI/CD pipeline configuration
- Rust (latest stable version)
 - Cargo (Rust package manager)
 - PostgreSQL (database)
 - RabbitMQ (message broker)
 
git clone https://github.com/GregTMJ/rabbitmq-async-example
cd rabbitmq-async-examplecp .env.example .envEdit the .env file with your specific configuration:
# RMQ main configs
RMQ_USER=user
RMQ_PASSWORD=bitnami
RMQ_HOST=lapin_rabbitmq
RMQ_PORT=5672
RMQ_VHOST=%2F
RMQ_EXCHANGE=servicehub
RMQ_EXCHANGE_TYPE=direct
RMQ_PREFETCH_COUNT=0
# RMQ exchange/queue configs
RMQ_REQUEST_QUEUE=servicehub.q.request
RMQ_RESPONSE_QUEUE=servicehub.q.response
RMQ_SERVICE_RESPONSE_QUEUE=servicehub.q.service_response
RMQ_DASHBOARD_SETTINGS_QUEUE=servicehub.q.dashboard_settings
RMQ_DASHBOARD_FANOUT_EXCHANGE=serhub_info_fanout_exchange
RMQ_TIMEOUT_QUEUE=timeout_requests
RMQ_DELAYED_EXCHANGE=delayed_exchange
# Postgres configs
POSTGRES_HOST=lapin_postgres
POSTGRES_PORT=5432
POSTGRES_DB=servicehub
POSTGRES_PASSWORD=LyhaEkM2D6TeH96W8jxG
POSTGRES_USER=servicehub
DATABASE_URL=postgres://servicehub:LyhaEkM2D6TeH96W8jxG@lapin_postgres:5432/servicehub
# Logging level configs
RUST_LOG=INFO
# Custom project configs
AVAILABLE_USERS=1,3,5,6,7,8,9,10,11,12
AVAILABLE_SERVICES=0,1,2,3,4,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52# Development build
cargo build
# Release build (optimized)
cargo build --releaseThe project includes comprehensive testing to ensure reliability and performance:
Core Test Categories:
- Unit Tests - Individual function and module testing
 - Integration Tests - Cross-module functionality testing
 - Database Tests - PostgreSQL operations and SQLx queries
 - RabbitMQ Tests - Message producer/consumer integration
 - Async Tests - Tokio runtime and asynchronous operations
 
Test Configuration:
- Tests run in isolated environments
 - Database transactions are rolled back after each test
 - RabbitMQ connections use test-specific queues
 - All I/O operations use mock implementations where appropriate
 
Coverage Tools:
- Automated coverage reporting in CI/CD
 - Regular coverage analysis
 - Coverage thresholds for new code
 
Test-Specific Configuration:
- Separate test database
 - Isolated RabbitMQ virtual hosts
 - Mock external service dependencies
 - Configurable test timeouts
 
Test Data Management:
- Factory functions for test data creation
 - Database seeding for integration tests
 - Clean state between test runs
 - Consistent test data patterns
 
| Status | Task | Description | Priority | 
|---|---|---|---|
| β Completed | Core Implementation | Basic async RabbitMQ client with Tokio | High | 
| π In Progress | Channel Management | Lapin channel reconnection handling | Critical | 
| β³ Planned | Database Optimization | SQLx connection pooling and query optimization | High | 
| β³ Planned | Error Handling | Comprehensive error management system | Medium | 
Version 1.5.0 - Stability & Bug Fixes
- Lapin dependency updates
 - Connection resilience improvements
 - Enhanced error recovery
 
Version 2.0.0 - Performance Enhancements
- Tokio runtime optimization
 - Message throughput improvements
 - Memory usage optimization
 
Version 3.0.0 - Production Ready
- Docker containerization
 - Kubernetes deployment support
 - Monitoring and metrics
 - Security hardening
 
Architecture Evolution:
- Microservices readiness
 - Event sourcing capabilities
 - Distributed tracing integration
 - Multi-tenancy support
 
Ecosystem Integration:
- OpenTelemetry support
 - Prometheus metrics
 - Grafana dashboards
 - Health check endpoints
 
We welcome contributions from the community! Here's how you can help:
Getting Started:
- Review open issues and feature requests
 - Check the roadmap for planned features
 - Discuss major changes via GitHub issues first
 - Follow Rust coding conventions and patterns
 
Code Quality Standards:
- All code must pass clippy checks
 - Tests required for new functionality
 - Documentation updates for API changes
 - Benchmarking for performance-critical code
 
Submission Guidelines:
- Use conventional commit messages
 - Include relevant test cases
 - Update documentation as needed
 - Ensure CI/CD pipelines pass
 
High Priority:
- RabbitMQ connection resilience
 - Performance optimization
 - Additional database support
 - Enhanced monitoring
 
Community Needs:
- Usage examples and tutorials
 - Integration guides
 - Troubleshooting documentation
 - Benchmark results
 
This project is licensed under the MIT License - see the LICENSE file for complete details.
Key Permissions:
- Commercial use
 - Distribution
 - Modification
 - Private use
 
Requirements:
- License and copyright notice preservation
 - Same license for substantial portions
 
No Limitations On:
- Liability
 - Warranty
 - Patent use
 - Trademark use
 
Community Resources:
- GitHub Discussions for questions
 - Issue tracker for bug reports
 - Documentation wiki for guides
 - Discord channel for real-time help
 
Professional Support:
- Coming soon: Enterprise support options
 - Planned: Commercial licensing
 - Future: Consulting services
 
Need help? Open an issue or join our community discussions!
Built with β€οΈ using Rust, Tokio, and RabbitMQ