Management via a REST API

Our last choice of management and controlling the RabbitMQ is using the REST API. RabbitMQ supports REST API to get lots of information from the RabbitMQ server and add, edit, and delete some parameters and properties on it.

As REST services rely on the HTTP protocol, we can easily communicate with RabbitMQ using web pages with AJAX, HTTP clients on every language, and so on. We'd like to show the examples that use RabbitMQ's REST API, using the Postman that is a REST client for Google Chrome. Postman is a free extension on Google Chrome, and you can add the Postman using the extension market of Google Chrome.

Before diving into the REST APIs, we'd like to talk about the authentication issue and return of the REST API after solving the issue. REST API of the RabbitMQ uses basic authentication and returns only JSON format. Therefore, we should configure our custom monitoring and managing tool with respect to these authentication and resource types. Lastly, RabbitMQ uses 55672 as a default port for the REST API port.

With the REST API, we can access the overview information about the RabbitMQ server. You should provide a username and password for basic authentication and just add the related URL for an overview of the REST API. Now, you are ready to send the request using the Send button, ah shown in the following image:

Management via a REST API

Overview Request

As we examined the screenshot of the overview result of REST API, we easily found the information and its statistics for RabbitMQ. We also found a similar view using the dashboard of the management web page.

Let's now move on to the queues and their details with the following image:

Management via a REST API

Queues Request

The queues service simply returns the list of all the queues, their information, and statistics. We can use these statistics to monitor our queues.

The following screenshot describes the connections service and type is JSON. The connections service simply returns the statistics and information about the current connections, which are established on the RabbitMQ server:

Management via a REST API

Connections Request

Similarly, we can control and monitor the channels using the REST API. As you can see in the following screenshot, we can fetch the information and statistics about the channels in the RabbitMQ server:

Management via a REST API

Channels Request

Statistics and information about the bindings can be easily fetched from the REST API as well.

Management via a REST API

Bindings Request

We sometimes need to view the permissions of the user within the RabbitMQ server instance. With the help of RabbitMQ's REST service, we can easily fetch and show the permissions of the user as shown in the following screenshot:

Management via a REST API

Permissions Request

As seen in the screenshots, both the services and results are in the JSON format. We can easily integrate them with our software system using the service-oriented architectures.

The RabbitMQ REST API has lots of services. Therefore, we can't show all of the services within screenshots of the each REST service. So, it is good to list all the services in a table. The following table just shows each service of the REST API of RabbitMQ with its HTTP methods and its description that explains the functionality of these parameters:

URL path

Available HTTP methods and description

/api/overview

HTTP Method: GET

This returns the state and related information about the RabbitMQ Broker.

/api/nodes/

HTTP Method: GET

This lists the nodes in the RabbitMQ cluster.

/api/nodes/name

HTTP Method: GET

This returns the information about the node that is specified with its name.

/api/extensions/

HTTP Method: GET

This returns the list of extensions in the Management plugin.

/api/definitions

HTTP Method: GET, POST

If the GET method is used, server definitions such as exchanges, queues, bindings, users, and virtual hosts are returned.

The POST method is used for uploading the existing set of definitions.

/api/connections

HTTP Method: GET

This returns the list of open connections.

/api/connections/name

HTTP Method: GET, DELETE

The GET method is used for fetching the information of the connection that is specified with a name.

The DELETE method is used for closing the connection.

/api/channels

HTTP Method: GET

This returns the list of all open channels.

/api/channels/channel

HTTP Method: GET

This returns the information of the channel that is specified with its name.

/api/exchanges

HTTP Method: GET

This returns a list of the exchanges.

/api/exchanges/vhost

HTTP Method: GET

This returns the list of the exchanges within the virtual host that is specified by the vhost parameter.

/api/queues

HTTP Method: GET

This returns the list of queues.

/api/queues/vhost

HTTP Method: GET

This returns the list of the queues within the virtual host that is specified by the vhost parameter.

/api/bindings

HTTP Method: GET

This returns the list of bindings.

/api/bindings/vhost

HTTP Method: GET

This returns the list of bindings within the virtual host, specified by vhost parameter.

/api/vhosts

HTTP Method: GET

This returns the list of the virtual hosts.

/api/vhosts/name

HTTP Method: GET, PUT, DELETE

If the GET method is used, it returns the information of the virtual host that is specified by its name.

The DELETE method is used for deleting the virtual host that is specified by its name.

The PUT method is used for putting a virtual host.

/api/users

HTTP Method: GET

This returns the list of the users.

/api/users/name

HTTP Method: GET, PUT, DELETE

If the GET method is used, it returns the information of the users that is specified by its name.

The DELETE method is used for deleting the user that is specified by its name.

The PUT method is used for putting a user.

/api/whoami

HTTP Method: GET

This returns the information of the current authenticated user.

/api/permissions

HTTP Method: GET

This returns the list of permissions.

/api/permissions/vhost/user

HTTP Method: GET, PUT, DELETE

If the GET method is used, it returns the information of the permissions that is specified by its virtual host and user.

The DELETE method is used for deleting the permissions of the user.

The PUT method is used for putting a policy.

/api/parameters

HTTP Method: GET

This returns the list of the parameters.

/api/parameters/component

HTTP Method: GET

This returns the list of the parameters for the provided component.

/api/policies

HTTP Method: GET

This returns the list of policies.

/api/policies/vhost

HTTP Method: GET

This returns the list of policies within the virtual host that is specified by the vhost parameter.

/api/aliveness-test/vhost

HTTP Method: GET

This makes tests for the given virtual host of the RabbitMQ server .

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

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