Message Queue Module (RabbitMQ)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Complete guide to deploying and managing RabbitMQ message broker with high availability, clustering, and monitoring capabilities.
🏗️ Overview
Section titled “🏗️ Overview”The RabbitMQ module provides a robust and scalable message broker that implements the Advanced Message Queuing Protocol (AMQP). It enables reliable message delivery, supports multiple messaging patterns, and provides comprehensive monitoring and management tools.
Architecture Components
Section titled “Architecture Components”RabbitMQ Deployment:├── RabbitMQ Server Pods (Cluster)├── Persistent Storage├── Management UI├── AMQP Protocol Support├── Health Monitoring└── Performance Metrics
🚀 Features
Section titled “🚀 Features”Message Broker Capabilities
Section titled “Message Broker Capabilities”- AMQP Protocol: Full support for Advanced Message Queuing Protocol
- Multiple Exchange Types: Direct, topic, fanout, and headers exchanges
- Queue Management: Durable, auto-delete, and priority queues
- Message Routing: Flexible routing with bindings and routing keys
High Availability
Section titled “High Availability”- Clustering: Multi-node cluster for fault tolerance
- Mirrored Queues: Queue replication across cluster nodes
- Automatic Failover: Seamless failover in case of node failure
- Load Balancing: Distributed message processing
Advanced Features
Section titled “Advanced Features”- Dead Letter Queues: Handle failed message processing
- Message TTL: Time-to-live for messages
- Priority Queues: Message prioritization
- Delayed Messages: Scheduled message delivery
- Publisher Confirms: Reliable message publishing
📦 Deployment Configuration
Section titled “📦 Deployment Configuration”Helmfile Configuration
Section titled “Helmfile Configuration”The RabbitMQ deployment uses Helmfile for environment management:
repositories: - name: bitnami url: https://charts.bitnami.com/bitnami
releases: - name: rabbitmq namespace: queue createNamespace: true chart: bitnami/rabbitmq values: - values.yaml
Core Configuration Values
Section titled “Core Configuration Values”auth: password: CHANGEME
# Basic configurationreplicaCount: 1
persistence: enabled: true size: 8Gi storageClass: "local-path"
resources: requests: memory: "256Mi" cpu: "250m" limits: memory: "512Mi" cpu: "500m"
service: type: ClusterIP
ingress: enabled: false
Advanced Configuration Options
Section titled “Advanced Configuration Options”# High-availability configurationreplicaCount: 3
# Clustering configurationclustering: enabled: true rebalance: true
# Performance tuningresources: requests: memory: "1Gi" cpu: "500m" limits: memory: "2Gi" cpu: "1000m"
# Security configurationauth: enabled: true password: "secure-password" erlangCookie: "SWQOKODSQALRPCLNMEQG"
# Monitoringmetrics: enabled: true serviceMonitor: enabled: true
# Management UImanagement: enabled: true ingress: enabled: true hostname: rabbitmq.theratap.de tls: true
🔧 RabbitMQ Configuration
Section titled “🔧 RabbitMQ Configuration”Cluster Configuration
Section titled “Cluster Configuration”# Cluster settingsclustering: enabled: true rebalance: true partitionHandlingStrategy: "autoheal"
# Erlang cookie for cluster communicationerlangCookie: "SWQOKODSQALRPCLNMEQG"
# Node namingnodeName: "rabbit@$(HOSTNAME).$(NAMESPACE).pod.cluster.local"
Queue Configuration
Section titled “Queue Configuration”# Default queue settingsdefaultQueueSettings: durable: true autoDelete: false arguments: x-message-ttl: 86400000 # 24 hours x-max-length: 10000 x-overflow: drop-head
# Dead letter configurationdeadLetterExchange: "dlx"deadLetterRoutingKey: "dlq"
Performance Tuning
Section titled “Performance Tuning”# Memory and disk thresholdsvmMemoryHighWatermark: relative: 0.6 # 60% of available memory
diskFreeLimit: relative: 2.0 # 2GB free disk space
# Connection limitsmaxConnections: 1000maxChannels: 2000
# Message size limitsmaxMessageSize: 134217728 # 128MB
📊 Monitoring & Metrics
Section titled “📊 Monitoring & Metrics”Health Checks
Section titled “Health Checks”# Check RabbitMQ service statuskubectl get pods -n queue -l app.kubernetes.io/name=rabbitmq
# Check service endpointskubectl get endpoints -n queue -l app.kubernetes.io/name=rabbitmq
# Test RabbitMQ connectivitykubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl status
Performance Monitoring
Section titled “Performance Monitoring”# Check resource usagekubectl top pods -n queue -l app.kubernetes.io/name=rabbitmq
# Monitor queue statisticskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name messages consumers
# Check connection statuskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_connections
# Monitor channel usagekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_channels
Key Metrics
Section titled “Key Metrics”# Queue depthkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name messages
# Message rateskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name message_stats.publish_details.rate
# Consumer countkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name consumers
# Memory usagekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl status | grep memory
Management UI
Section titled “Management UI”# Port forward management UIkubectl port-forward -n queue svc/rabbitmq 15672:15672
# Access management UIopen http://localhost:15672
# Default credentials# Username: admin# Password: (from auth.password in values.yaml)
Log Analysis
Section titled “Log Analysis”# View RabbitMQ logskubectl logs -n queue -l app.kubernetes.io/name=rabbitmq
# Follow logs in real-timekubectl logs -f -n queue deployment/rabbitmq
# Check for errorskubectl logs -n queue -l app.kubernetes.io/name=rabbitmq | grep ERROR
🚀 Deployment
Section titled “🚀 Deployment”Deploy RabbitMQ Module
Section titled “Deploy RabbitMQ Module”# Navigate to module directorycd iac/modules/rabbitmq
# Deploy using Helmfilehelmfile apply
# Verify deploymentkubectl get pods -n queuekubectl get services -n queue
Verify Deployment
Section titled “Verify Deployment”# Check pod statuskubectl get pods -n queue -l app.kubernetes.io/name=rabbitmq
# Test RabbitMQ connectionkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl status
# Check cluster statuskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl cluster_status
Post-Deployment Setup
Section titled “Post-Deployment Setup”# Port forward for local accesskubectl port-forward -n queue svc/rabbitmq 5672:5672
# Test with amqp-toolsamqp-declare-queue --url=amqp://admin:password@localhost:5672 -q test-queue
# Publish a test messageamqp-publish --url=amqp://admin:password@localhost:5672 -r test-queue -p "Hello RabbitMQ"
# Consume messagesamqp-consume --url=amqp://admin:password@localhost:5672 -q test-queue
🔧 Maintenance Operations
Section titled “🔧 Maintenance Operations”Queue Management
Section titled “Queue Management”# Create a queuekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl declare_queue name=my-queue durable=true
# List all queueskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues
# Purge a queuekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl purge_queue my-queue
# Delete a queuekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl delete_queue my-queue
Exchange Management
Section titled “Exchange Management”# Create an exchangekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl declare_exchange name=my-exchange type=direct durable=true
# List all exchangeskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_exchanges
# Delete an exchangekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl delete_exchange my-exchange
User Management
Section titled “User Management”# Create a userkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl add_user appuser apppassword
# Set user permissionskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl set_permissions -p / appuser ".*" ".*" ".*"
# List userskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_users
# Delete a userkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl delete_user appuser
Scaling Operations
Section titled “Scaling Operations”# Scale RabbitMQ replicaskubectl scale statefulset rabbitmq -n queue --replicas=3
# Verify cluster formationkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl cluster_status
# Rebalance clusterkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl rebalance
Update Operations
Section titled “Update Operations”# Update RabbitMQ versionhelmfile apply
# Monitor update progresskubectl rollout status statefulset/rabbitmq -n queue
# Rollback if neededkubectl rollout undo statefulset/rabbitmq -n queue
🚨 Troubleshooting
Section titled “🚨 Troubleshooting”Common Issues
Section titled “Common Issues”1. Connection Problems
Section titled “1. Connection Problems”# Check service connectivitykubectl get services -n queue
# Test network connectivitykubectl exec -it rabbitmq-0 -n queue -- nc -zv rabbitmq 5672
# Verify DNS resolutionkubectl exec -it rabbitmq-0 -n queue -- nslookup rabbitmq
2. Cluster Issues
Section titled “2. Cluster Issues”# Check cluster statuskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl cluster_status
# Check node healthkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl status
# Verify erlang cookiekubectl exec -it rabbitmq-0 -n queue -- cat /var/lib/rabbitmq/.erlang.cookie
3. Memory Issues
Section titled “3. Memory Issues”# Check memory usagekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl status | grep memory
# Check memory alarmskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_alarms
# Monitor disk usagekubectl exec -it rabbitmq-0 -n queue -- df -h
4. Queue Issues
Section titled “4. Queue Issues”# Check queue statuskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name messages consumers
# Check for unacknowledged messageskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name messages_unacknowledged
# Monitor message rateskubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl list_queues name message_stats
Recovery Procedures
Section titled “Recovery Procedures”Emergency Recovery
Section titled “Emergency Recovery”# Force delete stuck podskubectl delete pod rabbitmq-0 -n queue --grace-period=0 --force
# Reset cluster statekubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl stop_appkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl resetkubectl exec -it rabbitmq-0 -n queue -- rabbitmqctl start_app
# Rejoin cluster
🔒 Security Configuration
Section titled “🔒 Security Configuration”Authentication
Section titled “Authentication”# Enable authenticationauth: enabled: true password: "secure-password" erlangCookie: "SWQOKODSQALRPCLNMEQG"
# Network securitynetworkPolicy: enabled: true allowExternal: false ingressRules: primaryAccessOnlyFrom: enabled: true namespaceSelector: matchLabels: name: production podSelector: matchLabels: app.kubernetes.io/name: backend
SSL/TLS Configuration
Section titled “SSL/TLS Configuration”# TLS configurationtls: enabled: true secretName: rabbitmq-tls
# Certificate configurationcertificatesSecret: "rabbitmq-certs"
Access Control
Section titled “Access Control”# User permissionspermissions: - user: appuser vhost: / configure: ".*" write: ".*" read: ".*"
📝 Configuration Examples
Section titled “📝 Configuration Examples”High-Performance Configuration
Section titled “High-Performance Configuration”# High-performance valuesresources: requests: memory: 2Gi cpu: 1000m limits: memory: 4Gi cpu: 2000m
# Performance tuningconfiguration: |- vm_memory_high_watermark.relative = 0.6 disk_free_limit.relative = 2.0 max_connections = 1000 max_channels = 2000 max_message_size = 134217728
High-Availability Configuration
Section titled “High-Availability Configuration”# High-availability setupreplicaCount: 3
clustering: enabled: true rebalance: true partitionHandlingStrategy: "autoheal"
# Mirrored queuesdefaultQueueSettings: arguments: x-ha-policy: "all"
Monitoring-Optimized Configuration
Section titled “Monitoring-Optimized Configuration”# Enhanced monitoringmetrics: enabled: true serviceMonitor: enabled: true interval: 30s
management: enabled: true loadDefinitions: true definitions: queues: - name: "monitoring-queue" durable: true arguments: x-message-ttl: 3600000
🔄 Maintenance Schedule
Section titled “🔄 Maintenance Schedule”Daily Tasks
Section titled “Daily Tasks”- Monitor queue depths
- Check connection counts
- Review error logs
- Verify cluster health
Weekly Tasks
Section titled “Weekly Tasks”- Analyze performance metrics
- Review queue statistics
- Update user permissions
- Check for updates
Monthly Tasks
Section titled “Monthly Tasks”- Capacity planning review
- Performance optimization
- Security audit
- Disaster recovery testing
📋 Operational Checklist
Section titled “📋 Operational Checklist”Pre-Deployment
Section titled “Pre-Deployment”- Storage classes configured
- Persistent volumes available
- Network policies defined
- Authentication configured
- Cluster strategy defined
Post-Deployment
Section titled “Post-Deployment”- RabbitMQ service accessible
- Management UI functional
- Cluster formation verified
- Monitoring configured
- Application connectivity tested
Regular Maintenance
Section titled “Regular Maintenance”- Queue performance optimized
- Cluster health verified
- Security updates applied
- Capacity planning updated
- Disaster recovery tested
🔗 Related Documentation
Section titled “🔗 Related Documentation”- Backend Application - RabbitMQ integration
- Configuration Guide - Queue configuration
- Security Guide - Message queue security
- Performance Guide - Queue optimization
The RabbitMQ message queue module provides reliable message brokering with clustering, monitoring, and comprehensive management capabilities.