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:
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:
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:
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:
Statistics and information about the bindings can be easily fetched from the REST API as well.
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:
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: