Introduction
Learn about Arm-based cloud platforms for RabbitMQ
Create an Azure Cobalt 100 virtual machine
Install RabbitMQ on Azure Cobalt 100
Validate RabbitMQ on Azure
Create a firewall rule for RabbitMQ
Create a Google Axion C4A virtual machine
Install RabbitMQ on Google Cloud SUSE VM
Validate RabbitMQ on Google Cloud
RabbitMQ use Case 1 - event processing with Python Workers
RabbitMQ use case 2 - WhatsApp Notification
Next Steps
In this section you’ll implement a real-world asynchronous messaging pattern where RabbitMQ processes WhatsApp notifications reliably using a worker-based architecture.
In production systems, sending WhatsApp notifications must be:
RabbitMQ acts as a message broker to decouple message production from message consumption.
The architecture follows this flow:
pika Python client library installedInstall Python and the RabbitMQ Python client needed to build a consumer.
sudo zypper install -y python3 python3-pip
pip3 install pika
This use case uses a direct exchange topology for exact-match routing.
Exchanges:
notifications (direct): Routes WhatsApp notification messages based on an exact routing key match.Queue:
whatsapp.notifications (durable): Stores WhatsApp messages persistently until they are consumed by a worker.Binding:
notificationswhatsappwhatsapp.notificationsThis ensures only WhatsApp-related messages are routed to the final destination for processing.
Create the required exchange, queue, and binding for WhatsApp notifications.
./rabbitmqadmin declare exchange \
name=notifications \
type=direct \
durable=true
./rabbitmqadmin declare queue \
name=whatsapp.notifications \
durable=true
./rabbitmqadmin declare binding \
source=notifications \
destination=whatsapp.notifications \
routing_key=whatsapp
Each command confirms successful creation.
Verify that RabbitMQ resources exist and are correctly connected.
./rabbitmqadmin list queues name messages
./rabbitmqadmin list exchanges name type
./rabbitmqadmin list bindings
list queues displays all queues along with the number of messages currently stored in each queue.list exchanges lists all exchanges and their types, allowing verification of correct exchange configuration.list bindings shows how exchanges, queues, and routing keys are connected.The output shows you the following:
notifications exchange of type directwhatsapp.notifications durable queuewhatsapp)This confirms topology correctness before consuming messages.
> ./rabbitmqadmin list queues name messages
+------------------------+----------+
| name | messages |
+------------------------+----------+
| jobs | 0 |
| order.events | 1 |
| testqueue | 1 |
| whatsapp.notifications | 0 |
+------------------------+----------+
> ./rabbitmqadmin list exchanges name type
+--------------------+---------+
| name | type |
+--------------------+---------+
| | direct |
| amq.direct | direct |
| amq.fanout | fanout |
| amq.headers | headers |
| amq.match | headers |
| amq.rabbitmq.trace | topic |
| amq.topic | topic |
| events | topic |
| notifications | direct |
+--------------------+---------+
> ./rabbitmqadmin list bindings
+---------------+------------------------+------------------------+
| source | destination | routing_key |
+---------------+------------------------+------------------------+
| | jobs | jobs |
| | order.events | order.events |
| | testqueue | testqueue |
| | whatsapp.notifications | whatsapp.notifications |
| events | order.events | order.* |
| notifications | whatsapp.notifications | whatsapp |
+---------------+------------------------+------------------------+
Create a Python consumer (worker) that processes WhatsApp notification messages from the queue.
Create a file named whatsapp_worker.py with the following code:
import pika
import json
import time
RABBITMQ_HOST = "localhost"
RABBITMQ_VHOST = "/"
RABBITMQ_USER = "guest"
RABBITMQ_PASS = "guest"
QUEUE_NAME = "whatsapp.notifications"
credentials = pika.PlainCredentials(RABBITMQ_USER, RABBITMQ_PASS)
parameters = pika.ConnectionParameters(
host=RABBITMQ_HOST,
virtual_host=RABBITMQ_VHOST,
credentials=credentials,
heartbeat=60
)
print("[DEBUG] Connecting to RabbitMQ...")
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
print("[DEBUG] Declaring queue...")
channel.queue_declare(queue=QUEUE_NAME, durable=True)
print("[DEBUG] Setting QoS...")
channel.basic_qos(prefetch_count=1)
print("WhatsApp Worker started. Waiting for messages...")
def send_whatsapp(ch, method, properties, body):
data = json.loads(body.decode())
print(f"[Worker] Sending WhatsApp message to {data['phone']}")
print(f"[Worker] Message content: {data['message']}")
# Simulate external WhatsApp API call
time.sleep(1)
print("[Worker] Message sent successfully")
ch.basic_ack(delivery_tag=method.delivery_tag)
channel.basic_consume(
queue=QUEUE_NAME,
on_message_callback=send_whatsapp,
auto_ack=False
)
print("[DEBUG] Starting consumer loop (this should block)...")
channel.start_consuming()
Run the worker in a dedicated terminal session:
python3 whatsapp_worker.py
The worker runs correctly and waits for messages without exiting.
The output is similar to:
[DEBUG] Connecting to RabbitMQ...
[DEBUG] Declaring queue...
[DEBUG] Setting QoS...
WhatsApp Worker started. Waiting for messages...
[DEBUG] Starting consumer loop (this should block)...
The process blocks without returning to the shell prompt.
Open another SSH terminal and publish a WhatsApp notification message to RabbitMQ.
./rabbitmqadmin publish \
exchange=notifications \
routing_key=whatsapp \
payload='{"phone":"+911234567890","message":"Hello from RabbitMQ"}'
The output appears in the first terminal running whatsapp_worker.py:
[Worker] Sending WhatsApp message to +911234567890
[Worker] Message content: Hello from RabbitMQ
[Worker] Message sent successfully
The worker terminal displays the complete log:
[DEBUG] Connecting to RabbitMQ...
[DEBUG] Declaring queue...
[DEBUG] Setting QoS...
WhatsApp Worker started. Waiting for messages...
[DEBUG] Starting consumer loop (this should block)...
[Worker] Sending WhatsApp message to +911234567890
[Worker] Message content: Hello from RabbitMQ
[Worker] Message sent successfully
This confirms:
This validates the end-to-end message flow.
./rabbitmqadmin list queues name messages consumers
The output is similar to:
+------------------------+----------+-----------+
| name | messages | consumers |
+------------------------+----------+-----------+
| jobs | 0 | 0 |
| order.events | 2 | 0 |
| testqueue | 1 | 0 |
| whatsapp.notifications | 0 | 1 |
+------------------------+----------+-----------+
This confirms:
In this use case, you:
pika libraryThis pattern demonstrates how RabbitMQ enables asynchronous, decoupled communication for notification systems on Arm-based cloud platforms.