Mastering RabbitMQ: Architecture, Installation, and Webman Integration Guide
This guide explains RabbitMQ's core concepts, architecture, installation via 1Panel, configuration of the Webman RabbitMQ plugin, and demonstrates how to set up producers and consumers with code examples for reliable message handling.
RabbitMQ is an open‑source message broker that implements the Advanced Message Queuing Protocol (AMQP) and supports additional protocols such as STOMP and MQTT, making it compatible with many programming languages including Java, .NET, and Python.
AMQP stands for Advanced Message Queuing Protocol , an open standard application‑layer network protocol designed for message‑oriented middleware.
Basic Architecture
Image source: https://blog.csdn.net/cuierdan/article/details/123824300
Key Concepts
Message Broker : a virtual server that routes messages; RabbitMQ is an instance of a broker.
Producer : application that creates and sends messages to the broker.
Connection : TCP link between producer/consumer and the broker.
Channel : virtual connection multiplexed over a single TCP connection, similar to a DB connection pool.
VirtualHost : isolated namespace within RabbitMQ, analogous to a database schema.
Exchange : receives messages from producers and routes them to queues; types include fanout, direct, topic, and headers.
Binding : virtual link between an exchange and a queue, optionally using a binding key.
Routing Key : key used by an exchange to match bindings.
Queue : storage for messages awaiting consumption.
Consumer : application that retrieves messages from a queue.
Features
Reliability : persistence, delivery acknowledgments, and publisher confirms.
Flexible Routing : exchanges route messages before they reach queues.
Scalability : clusters of RabbitMQ nodes can be expanded dynamically.
High Availability : mirrored queues survive node failures.
Multiple Protocols : native AMQP plus STOMP, MQTT, etc.
Multi‑language Clients : Java, Python, Ruby, PHP, C#, JavaScript, and more.
Main Functions
Message Queuing : decouple producers and consumers.
Message Routing : direct messages to one or many receivers.
Message Persistence : prevent loss on system failure.
Message Acknowledgement : ensure proper processing and allow re‑delivery on failure.
Clustering : provide load balancing and fault tolerance.
Installation via 1Panel
1Panel is a modern open‑source Linux server management panel.
App Store
Installation Image
Note: enable "External Port Access" for local debugging.
Resulting Container
After successful installation, the RabbitMQ container appears in the image list.
External access URL: http://{{your_public_ip}}:15672. Open port 15672 in the cloud firewall if needed.
RabbitMQ Management Port : 15672 – web UI for monitoring.
AMQP Default Port : 5672 – protocol used by clients.
Using the Webman RabbitMQ Plugin
The plugin is hosted at https://www.workerman.net/plugin/67. Install it via Composer:
composer require workbunny/webman-rabbitmqEnsure the Webman framework is already installed (see https://www.workerman.net/doc/webman/install.html).
Configuration
Configuration file location:
config/plugin/workbunny/webman-rabbitmq/app.php <?php
return [
'enable' => true,
'host' => '120.120.120.74',
'vhost' => '/',
'port' => 5672,
'username' => 'rabbitmq',
'password' => 'rabbitmq',
'mechanisms' => 'AMQPLAIN',
// ...
];Replace host with your server's public IP.
Change port to 15672 if you wish to use the management UI.
Consumer Builder
Create a single‑process consumer using the built‑in RestyBuilder command:
./webman workbunny:rabbitmq-builder resty --mode=queue
ℹ️ Config updated.
ℹ️ Builder created.
✅ Builder RestyBuilder created successfully.The generated consumer class resides at process/workbunny/rabbitmq/RestyBuilder.php:
<?php declare(strict_types=1);
namespace process\workbunny\rabbitmq;
use Bunny\Channel as BunnyChannel;
use Bunny\Async\Client as BunnyClient;
use Bunny\Message as BunnyMessage;
use Workbunny\WebmanRabbitMQ\Constants;
use Workbunny\WebmanRabbitMQ\Builders\QueueBuilder;
class RestyBuilder extends QueueBuilder
{
protected array $queueConfig = [
'name' => 'process.workbunny.rabbitmq.RestyBuilder',
'delayed' => false,
'prefetch_count' => 0,
'prefetch_size' => 0,
'is_global' => false,
'routing_key' => '',
];
protected string $exchangeType = Constants::DIRECT;
protected ?string $exchangeName = 'process.workbunny.rabbitmq.RestyBuilder';
public function handler(BunnyMessage $message, BunnyChannel $channel, BunnyClient $client): string
{
echo '[RabbitMQ][Queue Consumer] Tag:' . $message->consumerTag . PHP_EOL;
echo '[RabbitMQ][Queue Consumer] Content:' . $message->content . PHP_EOL;
echo '[RabbitMQ][Queue Consumer] Exchange:' . $message->exchange . PHP_EOL;
return Constants::ACK;
}
}Running Webman
php start.php start
Workerman[start.php] start in DEBUG mode
----------------------------------------------------------------------- WORKERMAN -----------------------------------------------------------------------
Workerman version:4.1.15 PHP version:8.2.18 Event-Loop:\Workerman\Events\Event
------------------------------------------------------------------------ WORKERS ------------------------------------------------------------------------
proto user worker listen processes status
tcp root webman http://0.0.0.0:8217 2 [OK]
... (other workers listed)Producer Example
use function Workbunny\WebmanRabbitMQ\sync_publish;
use process\workbunny\rabbitmq\RestyBuilder;
sync_publish(RestyBuilder::instance(), 'RabbitMQ demo message'); // returns boolConsumer Output
[RabbitMQ][Queue Consumer] Tag:process.workbunny.rabbitmq.RestyBuilder
[RabbitMQ][Queue Consumer] Content:RabbitMQ demo message
[RabbitMQ][Queue Consumer] Exchange:process.workbunny.rabbitmq.RestyBuilder
... (subsequent messages)RabbitMQ Management UI
Send messages directly from the management UI.
View consumer consumption status.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
