A Rust implementation of enterprise integration patterns inspired by Apache Camel. This project demonstrates how to build a robust message processing system using Rust's async capabilities and clean architecture principles.
- Message processing pipeline similar to Apache Camel
- Clean Architecture implementation
- Async processing with Tokio
- REST API with Actix-web
- Docker support for development and production
- Comprehensive test suite
- Health check endpoints
- Logging and error handling
- Type-safe message processing
The project follows Clean Architecture principles with the following layers:
src/
├── domain/ # Core business logic and interfaces
│ ├── models/ # Domain entities
│ └── ports/ # Interface definitions
├── application/ # Use cases and business rules
│ ├── processors/ # Message processors
│ ├── pipeline/ # Processing pipeline
│ └── services/ # Application services
├── infrastructure/ # External implementations
│ ├── repositories/
│ └── adapters/
└── interfaces/ # Delivery mechanisms
├── api/ # REST API
└── cli/ # Command line interface
- Rust 1.75 or higher
- Docker and Docker Compose (optional)
- curl (for testing)
- Clone the repository:
git clone https://github.com/yourusername/rust-camel.git
cd rust-camel- Build the project:
cargo build- Run tests:
cargo test- Run the application:
cargo run- Development environment:
# Build and start development environment
./dev.sh build
./dev.sh start
# Run tests in Docker
./dev.sh test- Production environment:
# Build and start production environment
./dev.sh prod-build
./dev.sh prod-startcurl -X POST http://localhost:8080/api/messages \
-H "Content-Type: application/json" \
-d '{"body":"This is a test message"}'curl -X POST http://localhost:8080/api/messages/process \
-H "Content-Type: application/json" \
-d '{
"message_id":"<ID_FROM_PREVIOUS_RESPONSE>",
"additional_data":"optional extra information"
}'curl http://localhost:8080/healthThe application can be configured using environment variables:
RUST_LOG=debug # Log level (debug, info, warn, error)
RUST_BACKTRACE=1 # Enable backtracesThe project includes several types of tests:
- Unit tests:
cargo test- Specific test:
cargo test test_process_message- With logging:
RUST_LOG=debug cargo test -- --nocapture-
LoggingProcessor
- Logs message processing events
- Configurable prefix
-
EnricherProcessor
- Adds metadata to messages
- Configurable enrichment data
-
TransformProcessor
- Transforms message content
- Customizable transformation functions
-
FilterProcessor
- Filters messages based on conditions
- Configurable predicates
The project includes several development tools:
# Development script
./dev.sh [command]
Available commands:
build - Build development environment
start - Start development environment
stop - Stop development environment
test - Run tests
prod-build - Build production image
prod-start - Start production environment
logs - Show logs
clean - Clean up containers and volumes- Non-root user in production Docker image
- Proper error handling
- Input validation
- No sensitive data logging
- Health check endpoint
- Logging with different levels
- Docker healthcheck configuration
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Apache Camel
- Built with Rust and its amazing ecosystem
- Thanks to all contributors
Q: Why use Rust instead of Java/Apache Camel? A: Rust offers memory safety, zero-cost abstractions, and excellent performance. This implementation provides similar patterns with Rust's benefits.
Q: How do I add a new processor?
A: Implement the Processor trait for your new processor and add it to the pipeline. See existing processors for examples.
Q: How do I customize the processing pipeline?
A: Modify the pipeline configuration in main.rs to add, remove, or reorder processors.
Find me on twitter: @Iko Afianando
Project Link: https://github.com/IkoAfianando/rust-camel