Managing Plugins
1. Listing Available Plugins
| Command | Description | Notes |
|---|---|---|
| rabbitmq-plugins list | List all installed plugins | Shows plugin name, status (enabled/disabled), and version |
| rabbitmq-plugins list -E | List only enabled plugins | Useful for checking active configuration |
| rabbitmq-plugins list -D | List only disabled plugins | Helps identify plugins that can be enabled |
[ E] indicates an enabled plugin, while [ ] shows a disabled one.2. Enabling Plugin
| Command | Description | Notes |
|---|---|---|
| rabbitmq-plugins enable <plugin-name> | Enables a specific plugin | Plugin must be installed and available |
| rabbitmq-plugins enable --offline <plugin-name> | Enables plugin without restarting the broker | Requires RabbitMQ 3.10+ |
3. Disabling Plugin
| Command | Description | Notes |
|---|---|---|
| rabbitmq-plugins disable | Disables a specific plugin | Plugin must be installed and currently enabled |
4. Understanding Plugin Dependencies
| Dependency Type | Description | Example |
|---|---|---|
| Erlang Application | Core Erlang modules required for plugin functionality | ranch, ssl |
| RabbitMQ Core Feature | Features provided by RabbitMQ core that plugins may rely on | amqp_client, rabbit_common |
| External Library | Third-party libraries used by plugins (e.g., for parsing or encoding) | jiffy (JSON parser), cowboy (HTTP server) |
app.src file using the applications or included_applications attributes.Example: Plugin app.src dependency declaration
{application, rabbitmq_management,
[
{description, "RabbitMQ Management Plugin"},
{vsn, "3.12.0"},
{registered, []},
{applications, [
kernel,
stdlib,
ranch,
ssl,
amqp_client
]},
{included_applications, [rabbit_common]},
{mod, {rabbit_management_app, []}},
{env, [{http_port, 15672}]}
]}.
Dependency Resolution Process
- RabbitMQ loads plugins in dependency order
- Plugins with missing dependencies will not start
- Dependencies are resolved at runtime, not compile time
- Use
rabbitmq-plugins listto inspect loaded plugins and their dependencies
5. Using Management Plugin
| Command | Description | Notes |
|---|---|---|
| rabbitmq-plugins enable rabbitmq_management | Enables the management plugin | Required for web UI access |
| rabbitmq-plugins disable rabbitmq_management | Disables the management plugin | Stops web UI access |
guest/guest| Feature | Status | Description |
|---|---|---|
| Web UI | NEW | Provides real-time monitoring and management |
| API Access | NEW | REST API for plugin management |
6. Using Federation Plugin
The Federation plugin in RabbitMQ allows you to create federated exchanges and queues that span multiple nodes or clusters. It enables the creation of a distributed messaging topology by replicating messages across different RabbitMQ instances.
| Configuration Property | Description | Default Value | Notes |
|---|---|---|---|
| federation.plugin | Enables or disables the federation plugin | true |
Must be enabled to use federation features |
| federation.max-hops | Maximum number of hops for federated messages | 1 |
Prevents infinite loops in federation chains |
Example: Configuring Federation Exchange
{
"federation": {
"exchanges": [
{
"name": "federated-exchange",
"upstream": {
"uri": "amqp://user:pass@remote-server:5672/vhost",
"exchange": "source-exchange"
}
}
]
}
}
Example: Federating a Queue
{
"federation": {
"queues": [
{
"name": "federated-queue",
"upstream": {
"uri": "amqp://user:pass@remote-server:5672/vhost",
"queue": "source-queue"
}
}
]
}
}
rabbitmq_federation and rabbitmq_federation_management modules to be enabled on both source and target RabbitMQ nodes.
7. Using Shovel Plugin
The Shovel plugin in RabbitMQ is a powerful tool for transferring messages between different RabbitMQ brokers or between a broker and a non-RabbitMQ message broker. It is particularly useful for scenarios such as:
- Replicating messages across different RabbitMQ clusters
- Migrating from one broker to another
- Integrating with systems that do not use RabbitMQ
Example: Configuring a Shovel
{
"shovel": {
"source": {
"uri": "amqp://source-broker",
"queue": "source-queue"
},
"destination": {
"uri": "amqp://destination-broker",
"queue": "destination-queue"
},
"ack-mode": "on-confirm"
}
}
| Property | Description | Default Value |
|---|---|---|
| source.uri | URI of the source broker | None |
| source.queue | Queue name to consume from | None |
| destination.uri | URI of the destination broker | None |
| destination.queue | Queue name to publish to | None |
| ack-mode | Message acknowledgment mode | on-confirm |
8. Using Delayed Message Plugin
The rabbitmq_delayed_message_exchange plugin enables the use of delayed message delivery in RabbitMQ, allowing messages to be delivered at a specific time in the future.
| Property | Description | Default Value | Notes |
|---|---|---|---|
| delayed_message_exchange | Exchange type for delayed messages | x-delayed-message |
Must be used when declaring exchanges for delayed messages |
Example: Declaring a Delayed Exchange
const amqp = require('amqplib');
async function declareDelayedExchange() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
const exchangeName = 'delayed_exchange';
const exchangeType = 'x-delayed-message';
const options = {
durable: true,
arguments: {
'x-delayed-type': 'direct'
}
};
await channel.assertExchange(exchangeName, exchangeType, options);
console.log('Delayed exchange declared successfully');
await channel.close();
await connection.close();
}
declareDelayedExchange().catch(console.error);
Example: Publishing a Delayed Message
const amqp = require('amqplib');
async function publishDelayedMessage() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
const exchangeName = 'delayed_exchange';
const routingKey = 'delayed.routing.key';
const message = 'Hello, delayed world!';
const delayInMs = 5000; // 5 seconds
const messageOptions = {
headers: {
'x-delay': delayInMs
}
};
channel.publish(exchangeName, routingKey, Buffer.from(message), messageOptions);
console.log(`Message published with delay of ${delayInMs}ms`);
await channel.close();
await connection.close();
}
publishDelayedMessage().catch(console.error);
x-delay header must be an integer representing the delay in milliseconds.
rabbitmq_delayed_message_exchange plugin is enabled before attempting to use delayed messages.
Key Features of Delayed Message Plugin
- Supports delayed message delivery at a specific time in the future
- Uses
x-delayheader to specify delay duration in milliseconds - Exchange type
x-delayed-messageis required for delayed exchanges - Works with any exchange type (direct, topic, fanout, etc.) as the underlying type
9. Using Consistent Hash Exchange
The consistent hash exchange in RabbitMQ is used to distribute messages to queues based on a hash of the routing key, ensuring that messages with the same routing key are consistently routed to the same queue.
| Property | Description | Default Value | Notes |
|---|---|---|---|
| type | The exchange type for consistent hash | consistent-hash |
Must be set to consistent-hash |
| hash.algorithm | Algorithm used for hashing | md5 |
Can be md5, sha1, or sha256 |
Example: Declaring a Consistent Hash Exchange
const amqp = require('amqplib');
async function declareConsistentHashExchange() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
await channel.assertExchange('consistent-hash-exchange', 'consistent-hash', {
durable: true,
autoDelete: false
});
console.log('Consistent hash exchange declared');
await channel.close();
await connection.close();
}
declareConsistentHashExchange().catch(console.error);
Example: Publishing Messages to Consistent Hash Exchange
const amqp = require('amqplib');
async function publishToConsistentHashExchange() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
const exchangeName = 'consistent-hash-exchange';
const routingKey = 'user-123';
await channel.publish(exchangeName, routingKey, Buffer.from('Hello World'));
console.log(`Message published with routing key: ${routingKey}`);
await channel.close();
await connection.close();
}
publishToConsistentHashExchange().catch(console.error);
10. Using Top Plugin
| Command | Description | Notes |
|---|---|---|
| rabbitmq-top | Display real-time statistics for RabbitMQ nodes | Part of the rabbitmq_management plugin |
rabbitmq-top command provides a real-time view of RabbitMQ node metrics, including memory usage, disk space, and queue statistics.
11. Using Tracing Plugin
| Property | Value | Description |
|---|---|---|
| plugin.name | rabbitmq_tracing |
Name of the tracing plugin |
| enabled | true |
Whether the plugin is enabled |
| output.format | json |
Format of trace output (JSON or XML) |
12. Using Recent History Exchange
The Recent History Exchange plugin in RabbitMQ provides a way to store and retrieve recent messages for a specific queue or exchange. It's particularly useful for scenarios where you need to replay or inspect recent messages.
| Property | Description | Default Value | Notes |
|---|---|---|---|
| recent_history_exchange.max_age | Maximum age of messages to keep in the history | 3600 seconds (1 hour) | Can be specified in seconds, minutes, hours, etc. |
| recent_history_exchange.max_size | Maximum number of messages to keep in history | 1000 | Messages are evicted based on age first, then size |
| recent_history_exchange.ttl | Time To Live for messages in the exchange | 3600 seconds (1 hour) | Messages older than this will be removed |
Example: Configuring Recent History Exchange
// Enable the recent history exchange plugin
// rabbitmq-plugins enable rabbitmq_recent_history_exchange
// Configure exchange with default settings
const config = {
"recent_history_exchange": {
"max_age": 3600,
"max_size": 1000,
"ttl": 3600
}
};
// Apply configuration via RabbitMQ management API or config file
Example: Using Recent History Exchange in a Consumer
// Consume messages from recent history exchange
const amqp = require('amqplib');
async function consumeFromRecentHistory() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
// Bind queue to recent history exchange
await channel.assertExchange('recent_history_exchange', 'direct');
await channel.assertQueue('recent_history_queue');
await channel.bindQueue('recent_history_queue', 'recent_history_exchange', '#');
// Consume messages
channel.consume('recent_history_queue', (msg) => {
console.log('Received:', msg.content.toString());
channel.ack(msg);
});
}
consumeFromRecentHistory();
rabbitmq_recent_history_exchange to be enabled in RabbitMQ.