+
weaviate
+
grpc
+
+
+
+
notepad++
sqlite
fortran
soap
redis
+
+
php
android
bun
+
+
unix
===
d
surrealdb
rider
+
bash
===
+
+
jasmine
bash
weaviate
yaml
riot
istio
k8s
+
istio
asm
+
+
solid
neo4j
+
aurelia
+
โˆš
+
dns
helm
yarn
gin
+
+
+
jenkins
+
+
โˆˆ
unix
tls
c
+
azure
+
--
helm
haskell
+
+
+
tls
โ‰ˆ
spring
+
_
+
laravel
aws
bash
+
clion
+
+
+
docker
+
+
+
Back to Blog
๐Ÿ“ฌ RabbitMQ Message Broker on AlmaLinux: Reliable Message Queue System
rabbitmq messaging almalinux

๐Ÿ“ฌ RabbitMQ Message Broker on AlmaLinux: Reliable Message Queue System

Published Aug 29, 2025

Master RabbitMQ on AlmaLinux! Learn installation, queues, exchanges, clustering, and monitoring. Perfect beginner's guide to message-driven architecture!

5 min read
0 views
Table of Contents

๐Ÿ“ฌ RabbitMQ Message Broker on AlmaLinux: Reliable Message Queue System

Welcome to the amazing world of message brokers! ๐ŸŽ‰ Ready to make your applications talk to each other like never before? RabbitMQ is the postal service of the digital world - it ensures your messages get delivered reliably, even when things go wrong! Think of it as WhatsApp for your applications! ๐Ÿ’ฌโœจ

๐Ÿค” Why is RabbitMQ Important?

RabbitMQ revolutionizes how applications communicate! ๐Ÿš€ Hereโ€™s why itโ€™s incredible:

  • ๐Ÿ“ฎ Reliable Delivery - Messages never get lost, guaranteed!
  • ๐Ÿ”„ Decoupled Architecture - Apps work independently, no dependencies
  • โšก High Performance - Handles millions of messages per second
  • ๐ŸŒ Multiple Protocols - Supports AMQP, MQTT, STOMP, and more
  • ๐Ÿ“Š Load Balancing - Distribute work across multiple workers
  • ๐Ÿ›ก๏ธ Fault Tolerance - Keeps working even if servers fail

Itโ€™s like having a super-reliable postal service that never loses packages! ๐Ÿ“ฆ

๐ŸŽฏ What You Need

Before setting up your message highway, ensure you have:

  • โœ… AlmaLinux server (8 or 9)
  • โœ… Root or sudo access
  • โœ… At least 2GB RAM (4GB recommended)
  • โœ… 10GB free disk space
  • โœ… Basic terminal knowledge
  • โœ… Curiosity about messaging! ๐Ÿ“จ

๐Ÿ“ Step 1: Installing RabbitMQ - Your Messaging Engine!

Letโ€™s get RabbitMQ up and running! ๐Ÿƒโ€โ™‚๏ธ

First, install Erlang (RabbitMQโ€™s foundation):

# Install EPEL repository
sudo dnf install -y epel-release

# Install Erlang dependencies
sudo dnf install -y socat logrotate

# Add RabbitMQ repository
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

# Install Erlang
sudo dnf install -y erlang

# Verify Erlang installation
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell

Now install RabbitMQ:

# Add RabbitMQ repository
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

# Install RabbitMQ server
sudo dnf install -y rabbitmq-server

# Check version
sudo rabbitmqctl version

You should see:

3.12.x

Excellent! RabbitMQ is installed! ๐ŸŽ‰

๐Ÿ”ง Step 2: Starting and Configuring RabbitMQ - Bringing It to Life!

Time to start your message broker! ๐Ÿš€

# Start RabbitMQ service
sudo systemctl start rabbitmq-server

# Enable on boot
sudo systemctl enable rabbitmq-server

# Check status
sudo systemctl status rabbitmq-server

# Check cluster status
sudo rabbitmqctl cluster_status

Enable the management plugin (web UI):

# Enable management console
sudo rabbitmq-plugins enable rabbitmq_management

# List all plugins
sudo rabbitmq-plugins list

# Enable useful plugins
sudo rabbitmq-plugins enable rabbitmq_shovel rabbitmq_shovel_management
sudo rabbitmq-plugins enable rabbitmq_federation rabbitmq_federation_management
sudo rabbitmq-plugins enable rabbitmq_stomp rabbitmq_mqtt

Configure firewall:

# Open RabbitMQ ports
sudo firewall-cmd --permanent --add-port=5672/tcp  # AMQP
sudo firewall-cmd --permanent --add-port=15672/tcp # Management UI
sudo firewall-cmd --permanent --add-port=25672/tcp # Clustering
sudo firewall-cmd --reload

Access the web UI at http://your-server-ip:15672 ๐ŸŽŠ

๐ŸŒŸ Step 3: Creating Users and Permissions - Access Control!

Letโ€™s secure RabbitMQ with proper users! ๐Ÿ”

# Default credentials are guest/guest (localhost only)
# Create an admin user
sudo rabbitmqctl add_user admin StrongPassword123!

# Set admin tag
sudo rabbitmqctl set_user_tags admin administrator

# Set permissions (full access)
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

# Create application user
sudo rabbitmqctl add_user myapp AppPassword456!

# Set permissions for myapp (read/write to specific vhost)
sudo rabbitmqctl set_permissions -p / myapp "^myapp-.*" "^myapp-.*" "^myapp-.*"

# List users
sudo rabbitmqctl list_users

Create virtual hosts (isolated environments):

# Create virtual host for development
sudo rabbitmqctl add_vhost development

# Create virtual host for production
sudo rabbitmqctl add_vhost production

# Set user permissions on vhost
sudo rabbitmqctl set_permissions -p development myapp ".*" ".*" ".*"

# List vhosts
sudo rabbitmqctl list_vhosts

โœ… Step 4: Creating Queues and Exchanges - Message Routing!

Letโ€™s create your messaging infrastructure! ๐Ÿ“ก

Using the command line:

# Declare a queue
sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"/">>, queue, <<"my_queue">>}, true, false, [], none).'

# List queues
sudo rabbitmqctl list_queues

# Create exchange
sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"/">>, exchange, <<"my_exchange">>}, topic, true, false, false, []).'

# List exchanges
sudo rabbitmqctl list_exchanges

Better way - using Python client:

# Install Python client
sudo dnf install -y python3-pip
pip3 install pika

# Create a Python script
cat <<'EOF' > setup_rabbitmq.py
#!/usr/bin/env python3
import pika

# Connect to RabbitMQ
connection = pika.BlockingConnection(
    pika.ConnectionParameters('localhost',
                            credentials=pika.PlainCredentials('admin', 'StrongPassword123!'))
)
channel = connection.channel()

# Create a durable queue
channel.queue_declare(queue='task_queue', durable=True)
print("โœ… Created queue: task_queue")

# Create a topic exchange
channel.exchange_declare(exchange='logs', exchange_type='topic')
print("โœ… Created exchange: logs")

# Create fanout exchange for broadcasting
channel.exchange_declare(exchange='broadcasts', exchange_type='fanout')
print("โœ… Created exchange: broadcasts")

# Bind queue to exchange
channel.queue_bind(queue='task_queue', exchange='logs', routing_key='*.critical')
print("โœ… Bound queue to exchange")

connection.close()
EOF

# Run setup
python3 setup_rabbitmq.py

๐Ÿš€ Step 5: Publishing and Consuming Messages - Making It Work!

Time to send and receive messages! ๐Ÿ’Œ

Create a publisher:

# publisher.py
cat <<'EOF' > publisher.py
#!/usr/bin/env python3
import pika
import sys
import json
from datetime import datetime

# Connect
connection = pika.BlockingConnection(
    pika.ConnectionParameters('localhost',
                            credentials=pika.PlainCredentials('admin', 'StrongPassword123!'))
)
channel = connection.channel()

# Ensure queue exists
channel.queue_declare(queue='task_queue', durable=True)

# Create message
message = {
    'id': 1,
    'task': 'Process order',
    'timestamp': datetime.now().isoformat(),
    'data': {'order_id': 12345, 'amount': 99.99}
}

# Send message
channel.basic_publish(
    exchange='',
    routing_key='task_queue',
    body=json.dumps(message),
    properties=pika.BasicProperties(
        delivery_mode=2,  # Make message persistent
    )
)

print(f"๐Ÿ“ค Sent: {message}")
connection.close()
EOF

python3 publisher.py

Create a consumer:

# consumer.py
cat <<'EOF' > consumer.py
#!/usr/bin/env python3
import pika
import json
import time

# Connect
connection = pika.BlockingConnection(
    pika.ConnectionParameters('localhost',
                            credentials=pika.PlainCredentials('admin', 'StrongPassword123!'))
)
channel = connection.channel()

# Ensure queue exists
channel.queue_declare(queue='task_queue', durable=True)

def callback(ch, method, properties, body):
    message = json.loads(body)
    print(f"๐Ÿ“ฅ Received: {message}")
    
    # Simulate work
    time.sleep(2)
    print(f"โœ… Processed order {message['data']['order_id']}")
    
    # Acknowledge message
    ch.basic_ack(delivery_tag=method.delivery_tag)

# Configure consumer
channel.basic_qos(prefetch_count=1)  # Fair dispatch
channel.basic_consume(queue='task_queue', on_message_callback=callback)

print('โณ Waiting for messages. Press CTRL+C to exit')
channel.start_consuming()
EOF

python3 consumer.py

๐ŸŽฏ Step 6: Setting Up Clustering - High Availability!

Create a RabbitMQ cluster for reliability! ๐ŸŒ

On the first node:

# Get Erlang cookie (cluster secret)
sudo cat /var/lib/rabbitmq/.erlang.cookie

# Check node name
sudo rabbitmqctl eval 'node().'

On additional nodes:

# Stop RabbitMQ
sudo systemctl stop rabbitmq-server

# Copy Erlang cookie from first node
echo "COOKIE_FROM_FIRST_NODE" | sudo tee /var/lib/rabbitmq/.erlang.cookie
sudo chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
sudo chmod 400 /var/lib/rabbitmq/.erlang.cookie

# Start RabbitMQ
sudo systemctl start rabbitmq-server

# Join cluster
sudo rabbitmqctl stop_app
sudo rabbitmqctl join_cluster rabbit@node1
sudo rabbitmqctl start_app

# Check cluster status
sudo rabbitmqctl cluster_status

Configure mirrored queues for HA:

# Set HA policy for all queues
sudo rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all","ha-sync-mode":"automatic"}'

# Set HA for specific queues
sudo rabbitmqctl set_policy ha-critical "^critical-" '{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic"}'

๐ŸŽฎ Quick Examples

Example 1: Work Queue Pattern

Distribute tasks among workers:

# Create multiple workers that share the load
# Worker will process one message at a time
# Messages are distributed round-robin

Example 2: Publish/Subscribe Pattern

Broadcast messages to multiple consumers:

# Create fanout exchange for broadcasting
sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"/">>, exchange, <<"news">>}, fanout, true, false, false, []).'

# Each consumer creates its own queue and binds to exchange
# All consumers receive all messages

Example 3: RPC over RabbitMQ

Request-response pattern:

# Client sends request with correlation_id and reply_to queue
# Server processes and sends response to reply_to queue
# Client matches response using correlation_id

๐Ÿšจ Fix Common Problems

Problem 1: Cannot Connect to RabbitMQ

Symptom: Connection refused errors ๐Ÿ˜ฐ

Fix:

# Check if service is running
sudo systemctl status rabbitmq-server

# Check logs
sudo journalctl -u rabbitmq-server -n 50

# Check listeners
sudo netstat -tlnp | grep beam

# Reset node if needed
sudo rabbitmqctl stop_app
sudo rabbitmqctl reset
sudo rabbitmqctl start_app

Problem 2: Memory/Disk Alarms

Symptom: RabbitMQ stops accepting messages ๐Ÿšซ

Fix:

# Check resource usage
sudo rabbitmqctl status | grep -A 5 "Memory"

# Set memory high watermark
sudo rabbitmqctl set_vm_memory_high_watermark 0.6

# Set disk free limit
sudo rabbitmqctl set_disk_free_limit 2GB

# Clear queues if needed
sudo rabbitmqctl purge_queue queue_name

Problem 3: Lost Messages

Symptom: Messages disappear! ๐Ÿ‘ป

Fix:

# Make queues durable
# Set delivery_mode=2 for persistent messages
# Use publisher confirms
# Enable HA policies for critical queues

# Check for unacknowledged messages
sudo rabbitmqctl list_queues name messages_ready messages_unacknowledged

๐Ÿ“‹ Simple Commands Summary

CommandWhat It DoesWhen to Use
rabbitmqctl statusServer statusHealth check
rabbitmqctl list_queuesShow queuesMonitor queues
rabbitmqctl list_exchangesShow exchangesCheck routing
rabbitmqctl list_bindingsShow bindingsDebug routing
rabbitmqctl list_connectionsActive connectionsMonitor clients
rabbitmqctl list_channelsOpen channelsCheck activity
rabbitmqctl add_userCreate userAdd access
rabbitmqctl set_policySet HA policyConfigure HA
rabbitmqctl cluster_statusCluster infoCheck nodes
rabbitmq-plugins enableEnable pluginAdd features

๐Ÿ’ก Tips for Success

๐Ÿš€ Performance Optimization

Make RabbitMQ blazing fast:

# Increase file descriptors
echo "rabbitmq soft nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "rabbitmq hard nofile 65536" | sudo tee -a /etc/security/limits.conf

# Optimize Erlang VM
echo "SERVER_ERL_ARGS=\"+K true +A 128 +P 1048576\"" | sudo tee -a /etc/rabbitmq/rabbitmq-env.conf

# Use lazy queues for large messages
sudo rabbitmqctl set_policy lazy-queues "^lazy\." '{"queue-mode":"lazy"}'

๐Ÿ“Š Monitoring Best Practices

Keep an eye on everything:

  1. Queue depth - Watch for backing up! ๐Ÿ“ˆ
  2. Connection count - Monitor client connections! ๐Ÿ”Œ
  3. Memory usage - Prevent alarms! ๐Ÿ’พ
  4. Message rates - Track throughput! โšก
  5. Disk space - Avoid failures! ๐Ÿ’ฟ
# Enable Prometheus metrics
sudo rabbitmq-plugins enable rabbitmq_prometheus

# Access metrics at http://server:15692/metrics

๐Ÿ”’ Security Hardening

Keep RabbitMQ secure:

# Enable SSL/TLS
# Disable guest user
sudo rabbitmqctl delete_user guest

# Use strong passwords
# Enable audit logging
sudo rabbitmq-plugins enable rabbitmq_audit

๐Ÿ† What You Learned

Youโ€™re now a RabbitMQ expert! ๐ŸŽ“ Youโ€™ve successfully:

  • โœ… Installed RabbitMQ message broker
  • โœ… Configured users and permissions
  • โœ… Created queues and exchanges
  • โœ… Published and consumed messages
  • โœ… Set up clustering for HA
  • โœ… Learned troubleshooting
  • โœ… Mastered management commands

Your applications can now communicate reliably! ๐Ÿ“ฌ

๐ŸŽฏ Why This Matters

RabbitMQ gives you architectural superpowers! With your message broker, you can:

  • ๐Ÿ—๏ธ Build microservices - Decouple everything!
  • ๐Ÿ“Š Handle traffic spikes - Queue manages load!
  • ๐Ÿ”„ Process asynchronously - No more waiting!
  • ๐Ÿ›ก๏ธ Ensure reliability - Messages never lost!
  • ๐Ÿš€ Scale horizontally - Add workers anytime!

Youโ€™re not just passing messages - youโ€™re building resilient, scalable, and maintainable distributed systems! Your architecture is now event-driven and future-proof! ๐ŸŒŸ

Keep messaging, keep scaling, and remember - with RabbitMQ, every message matters! โญ

May your queues be short and your throughput be high! ๐Ÿš€๐Ÿ“ฌ๐Ÿ™Œ