Let’s kick off the conversation on a note that’s not directly related to RabbitMQ Plugins, but returning to establish the connection eventually.
Some software systems are designed to allow other programs to extend or modify their functionality.
As an example, I’ve always installed extensions in my internet browsers to extend their capabilities beyond the standard features. I never understood how these browsers support this level of extensibility, but after building a basic browser extension (no longer functional though), I grasped how products like Google Chrome are designed.
They embrace the plugin or microkernel architecture. IDEs like Eclipse and VS Code also implement this architecture. But what can we learn about the plugin architecture when it comes to RabbitMQ?
This article describes the plugin architecture, how it relates to RabbitMQ plugins, and most importantly what RabbitMQ plugins are.
What is Plugin Architecture?
The plugin architecture is a pattern where a larger system is designed to allow sub-programs to hook into it. The larger system is called the core system and the subprograms are called the plugins. The core system loads and executes the plugins that in turn modify or add to the behavior of the core system.
The core system integrates seamlessly with its plugins because it expects all its plugins to align with some specification. For example, the core system could specify the class or methods that all plugins must implement.
Still not clear? Okay, think of a core system and its plugins in terms of a jigsaw puzzle with an infinite number of pieces. The jigsaw puzzle is the core system and the new pieces added are the plugins.
The jigsaw puzzle (core system) defines the shape of allowable new pieces (plugins). New pieces that fit the predefined shape hook into the jigsaw and add value. The pieces that don’t are rejected. The image below demonstrates this metaphor.
A core system and its plugins as a jigsaw puzzle with new pieces
But how do all these relate to RabbitMQ plugins?
RabbitMQ Plugin
RabbitMQ also adopts the plugin or microkernel architecture. As a result, RabbitMQ plugins are to RabbitMQ what extensions are to internet browsers or IDEs. Plugins in RabbitMQ hook into the core RabbitMQ system and extend the broker functionality in a variety of ways.
For example, the consistent hash exchange type plugin extends RabbitMQ beyond the standard exchange types it provides. There are more, and generally speaking, a RabbitMQ plugin is either a 1st tier or a 3rd tier plugin.
The core RabbitMQ distribution comes bundled with first tier plugins. In other words, you do not have to install first tier plugins, you just enable them (more on this later). A list of all the first tier RabbitMQ plugins can be found here.
Third tier plugins, on the other hand, are not bundled into the core RabbitMQ distribution. Instead, you’d have to find, install, and enable them. The third tier plugins are contributed by authors in the RabbitMQ community. See the community plugins page for more details.
How the Plugin System Works in RabbitMQ
The plugin system in RabbitMQ works pretty much the same way it works in most plugin-oriented architectures. This article will briefly cover this at a very high level.
There are four moving parts to the internal workings of the RabbitMQ plugin system:
- The core RabbitMQ program – The main system whose features we want to extend
- The plugin loader – In a plugin system, the plugins need a mechanism to announce/register their presence with the core system. The plugin loader solves this problem in RabbitMQ. It is responsible for loading enabled RabbitMQ plugins into the same Erlang VM as the broker. In RabbitMQ, the loader loads these enabled plugins from the plugins directory in that it knows where to find these plugins.
- Hooks – The core RabbitMQ system provides extension points through which plugins can hook into the core system and execute. For example, all enabled plugins are loaded and executed upon the boot of a RabbitMQ node.
- The plugins – The first or third tier plugins that the loader loads into the core system
The image below illustrates the interplay between these four moving parts.
Discovering Official RabbitMQ Plugins
Use the
rabbitmq-plugins list
command to discover official RabbitMQ plugins.
This feature works much like the package search tool in most Linux operating
systems. It will only list officially supported plugins and those already
added to the plugins folder.
$ rabbitmq-plugins list
It is possible to limit results by appending a regular expression such as
management* to the end of the command. As shown in the figure below, where the
command
rabbitmq-plugins list management*
is used. In the image, we can also
see that the
rabbitmq_management
,
rabbitmq_management_agent
,
and
rabbitmq_shovel_management
plugins are enabled, but not the
rabbitmq_federation_management
plugin.
Installing RabbitMQ Plugins
Administrators can turn features on and off with the
rabbitmq-plugins
command.
You can only turn on/off a plugin in this way if it’s listed in the plugins
directory.
Download and copy the plugin to the expected directory if it is not officially
supported. Then run
rabbitmq-plugins enable
.
If this fails, make sure that
your add-on works with your version of RabbitMQ. Plugin developers typically
list compatible broker versions in their documentation.
$ sudo rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@host:
rabbitmq_management
The following plugins have been configured:
rabbitmq_consistent_hash_exchange
rabbitmq_event_exchange
rabbitmq_federation
rabbitmq_management
rabbitmq_management_agent
rabbitmq_shovel
rabbitmq_web_dispatch
Enabling RabbitMQ Plugins on CloudAMQP
CloudAMQP has simplified every aspect of the enabling/disabling of plugins. The CloudAMQP dashboard lists the most common/used RabbitMQ plugins and can easily be turned on/off in the web browser. When you have created an instance, simply go to the plugins tab in the CloudAMQP dashboard to turn on and off the plugins of your choice.
Enabled plugins continue to run until they are disabled, using CPU and memory. We recommend making sure to disable unused plugins. Keep in mind that some plugins may conflict with each other. There are two different x509 authentication plugins for instance. Keeping on top of your plugins helps eliminate conflicts while improving performance.
Summary
This article focused on how RabbitMQ leverages the plugin architecture. RabbitMQ plugins are excellent because they extend the capabilities of RabbitMQ beyond its standard set of functionalities. This in turn fosters the proliferation of RabbitMQ plugins created by developers and fans of RabbitMQ that want to make it even better.
As a result, you can always install and enable a plugin to fit your RabbitMQ use case, or you can even build your own RabbitMQ plugin.
Ready to spin up a RabbitMQ instance? Create a free RabbitMQ instance at CloudAMQP.
Email contact@cloudamqp.com with any suggestions, questions, or feedback.