Chapter 5. Plugins and Plugin Development

Today, plugins are the main extending point of the software systems. As we know from other software projects, plugins are used to extend the capability or add any other skills to the software system.

RabbitMQ has its own plugin system, and it gives us default plugins as well. Moreover, RabbitMQ gives us one more opportunity: developing our custom plugin using RabbitMQ's API.

In this chapter, we will discuss the details of the plugins, default plugins and custom plugin development, as the following list describes:

  • Plugin management and default plugins
  • Plugin configuration
  • Custom plugin development

Plugin management and default plugins

RabbitMQ provides a number of tools that aid us in plugin management. Additionally, RabbitMQ provides lots of default plugins to monitor, manage, add features, and so on to RabbitMQ. Plugins are crucial because they introduce an important set of new features, making RabbitMQ easier to use and manage.

Now, we are ready to talk about enabling and disabling plugins.

Enabling and disabling plugins

RabbitMQ provides a plugin management tool called rabbitmq-plugins. rabbitmq-plugins is a command line tool to enable, disable, and list the plugins within the RabbitMQ server. The rabbitmq-plugins command will enable or disable plugins by updating the plugin configuration file. It will then contact the running server to tell it to start or stop plugins as needed. You can use the -n option to specify a different node, or use --offline to only change the file.

As all management tools of RabbitMQ need write permissions, rabbitmq-plugins also needs write permissions to get allowed to be run by the user. General usage of the tool is as follows:

rabbitmq-plugins {command} [command param1, command param2,…]

The functions and the parameters of rabbitmq-plugins are listed in the following table:

Command Name

Command Parameters

Command Description

list

-v, -m, -E, -e, pattern

Lists all plugins with their versions and dependencies.

-v parameter shows all the plugin details.

-m parameter shows only plugin names.

-E parameter shows only explicitly enabled plugins.

-e parameter shows only explicitly or implicitly enabled plugins.

pattern parameter shows only the plugins that match with the defined pattern.

Example:

rabbitmq-plugins list
rabbitmq-plugins list -v
rabbitmq-plugins list -m

enable

Plugin Name1, Plugin Name2

Enables the provided plugins. We can use multiple plugin names as a parameter.

Example:

rabbitmq-plugins enable rabbitmq_management

disable

Plugin Name1, Plugin Name2

Disables the provided plugins. We can use multiple plugin names as a parameter.

Example:

rabbitmq-plugins disable rabbitmq_stomp

Table 1: rabbitmq-plugins commands and its parameters

The following screenshot of command line shows how to run listing command of rabbitmq-plugins:

Enabling and disabling plugins

Listing of Plugins

In addition, the following screenshot of command line shows how to enable or disable any plugin using the command of enable or disable of rabbitmq-plugins:

Enabling and disabling plugins

Enabling and Disabling of Plugins

Installing plugin from third-party sources

RabbitMQ gives us another opportunity to develop our own plugins using Erlang language. Moreover, lots of plugins developed by individual developers can be found on the Internet.

Now, it is time to show you how to install a plugin from source code to be enabled on the RabbitMQ Server.

Firstly, we will choose one of the open source plugins called RabbitMQ Random Exchange Type plugin, which can be fetched from git://github.com/jbrisbin/random-exchange.git via Git source code management tool using the following command:

git clone git://github.com/jbrisbin/random-exchange.git
cd random-exchange
make package
cp dist/*.ez $RABBITMQ_HOME/plugins

Then, we go to the created folder called random-exchange. After that, we build the source code and copy the built files to $RABBITMQ_HOME/plugins using the following commands:

make package
cp dist/*.ez $RABBITMQ_HOME/plugins

Now, we are ready to enable our third party plugin using the following command with the help of rabbitmq-plugins tool:

rabbitmq-plugins enable random-exchange

Default plugin list

RabbitMQ contributors publish the default plugins that will be helpful to add new protocols, some authentication functionality on RabbitMQ Server, and so on. Moreover, some experimental plugins published by the contributors are also a part of these publications.

To talk in detail regarding the plugins, let's move on to the following table that shows the default plugins and their description:

Plugin Name

Plugin Description

rabbitmq_auth_backend_ldap

To use external LDAP as authentication or authorization functionality. This plugin will be explained in detail in Chapter 8, Security in RabbitMQ.

rabbitmq_auth_mechanism_ssl

To add authentication mechanism using SSL certificates. This plugin will be explained in detail in Chapter 8, Security in RabbitMQ.

rabbitmq_consistent_bash_exchange

To provide the consistent hashing on the exchanges to ensure that all queues bound to exchange will receive an equal number of messages.

rabbitmq_federation

To transmit messages between brokers without clustering within wide area networks. Provides scalability skills. This plugin was explained in detail in Chapter 3, Architecture and Messaging.

rabbitmq_federation_management

To manage the federation plugin in RabbitMQ Server with provided API and UI. Federation Management plugin is active when the RabbitMQ Management plugin is also active.

rabbitmq_management

To monitor and manage RabbitMQ using web based applications. Applications use RabbitMQ API, one of the most useful plugins in RabbitMQ.

rabbitmq_management_agent

To monitor and manage the clusters of the RabbitMQ needs.

rabbitmq_mqtt

Enables the supporting of MQTT 3.1 protocol in RabbitMQ. MQTT is simply defined as lightweight publish/subscribe messaging transport.

rabbitmq_shovel

Enables the ability to continually consume messages from one queue and publish them to exchanges in another broker. This plugin's functionality was explained in Chapter 3, Architecture and Messaging.

rabbitmq_shovel_management

To monitor and manage the shovel in RabbitMQ Server with provided UI and API. Shovel Management plugin is active when the RabbitMQ Management plugin is active.

rabbitmq_stomp

Enables the gateway to expose the AMQP functionality using the STOMP protocol that provides an interoperable wire format.

As discussed earlier, contributors publish some experimental plugins; for instance, supporting the AMQP version 1.0 plugin. The following table shows the details of the experimental plugins and their description:

Plugin Name

Plugin Description

rabbitmq_amqp1_0

Enables the AMQP version 1.0 RabbitMQ Server.

rabbitmq_jsonrpc_channel

Enables the AMQP over HTTP protocol using jsonrpc. Moreover, this plugin provides JavaScript libraries to communicate with RabbitMQ.

rabbitmq_jsonrpc_channel_examples

To provide the examples of AMQP over HTTP, such as shared whiteboard, chat application, and some tests.

rabbitmq_management_visualizer

Visualizes the broker topology using the management web application by adding the Visualizer tab.

rabbitmq_tracing

Enables message tracing and logging.

rabbitmq_web_stomp

To attach rabbitmq_stomp to web browsers using the HTML 5 WebSockets layer SockJS.

rabbitmq_web_stomp_examples

To provide the rabbitmq_web_stomp examples, such as simple collaboration tool.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset