Why RabbitMQ + MySQL?
- RabbitMQ: Battle-tested message broker with flexible routing and excellent observability
- MySQL: Popular relational database with broad ecosystem support
- Use case: Teams familiar with RabbitMQ and MySQL, or requiring specific RabbitMQ features
Prerequisites
- Docker and Docker Compose installed
- Lemline built locally (see Installation)
- Basic understanding of RabbitMQ and MySQL
Quick Start
# Lemline Configuration: RabbitMQ + MySQL
lemline:
database:
mysql:
host: localhost
port: 3306
database: lemline
username: lemline
password: lemline
messaging:
rabbitmq:
hostname: localhost
port: 5672
username: guest
password: guest
LEMLINE_CONFIG=./examples/lemline-rabbit-mysql.yaml \
java -jar lemline-runner/build/quarkus-app/quarkus-run.jar listen
Configuration Details
MySQL Settings
RabbitMQ Settings
Database Schema
Lemline automatically creates the necessary tables:- workflow_definitions: Workflow DSL definitions
- workflow_instances: Active and completed workflow instances
- workflow_waits: Scheduled tasks and timeouts
- workflow_listeners: Event listeners and subscriptions
- workflow_retries: Retry state for failed tasks
- workflow_failures: Terminal failures and errors
- lifecycle_analytics: Execution metrics and history
RabbitMQ Topology
Lemline uses RabbitMQ exchanges and queues:Exchanges
- lemline.commands: Topic exchange for routing commands
- lemline.events: Topic exchange for CloudEvents
Queues
- lemline.commands-in: Incoming workflow commands (start, resume, cancel)
- lemline.commands-out: Outgoing workflow commands for task execution
- lemline.events-out: CloudEvents produced by workflows
Bindings
- Commands are routed to queues based on routing keys
- Multiple Lemline instances share the same queues (competing consumers)
- Events are published to the events exchange
RabbitMQ Management UI
Access the RabbitMQ management UI at http://localhost:15672 Default credentials:- Username:
guest - Password:
guest
- View queues and message counts
- Monitor consumer activity
- Inspect message payloads
- Manage exchanges and bindings
- View connection and channel statistics
Horizontal Scaling
Run multiple Lemline instances to scale horizontally:Monitoring
MySQL Monitoring
Connect to MySQL to query workflow state:RabbitMQ Metrics
Use the management UI or CLI to monitor:Production Considerations
Database connection pooling
Database connection pooling
Configure appropriate pool sizes based on your workload:
RabbitMQ clustering
RabbitMQ clustering
For production, use a RabbitMQ cluster:
- At least 3 nodes for high availability
- Configure mirrored queues for fault tolerance
- Use a load balancer for connection distribution
MySQL tuning
MySQL tuning
Optimize MySQL for your workload:
- Increase
max_connectionsfor concurrent workflows - Tune
innodb_buffer_pool_size - Configure appropriate backup and replication
- Consider using ProxySQL for connection pooling
Security
Security
- Enable SSL/TLS for RabbitMQ connections
- Use SSL for MySQL connections
- Create dedicated users with minimal privileges
- Rotate credentials regularly
- Use RabbitMQ virtual hosts to isolate environments
- Restrict network access with firewalls
Message Durability
RabbitMQ can persist messages to disk for durability:Troubleshooting
RabbitMQ Connection Refused
Error:java.net.ConnectException: Connection refused
Solution: Ensure RabbitMQ is running and accessible:
MySQL Connection Errors
Error:Access denied for user 'lemline'@'localhost'
Solution: Check MySQL status and credentials:
Queue Not Found
Error:Queue 'lemline.commands-in' not found
Solution: Lemline declares queues automatically. If the error persists, check RabbitMQ logs for permission issues.
Message Buildup
Symptom: Messages accumulating in queues Solution:- Check Lemline logs for errors
- Verify consumers are connected (RabbitMQ UI)
- Scale horizontally by adding more Lemline instances
- Check for slow downstream services
Stopping the Infrastructure
Next Steps
Kafka + PostgreSQL
Try Kafka for higher throughput
PGMQ Setup
Use PostgreSQL for both messaging and storage
Production Deployment
Deploy Lemline to production
Monitoring
Set up metrics and monitoring