RabbitMQ RabbitMQ RabbitMQ RabbitMQ RabbitMQ RabbitMQ RabbitMQ RabbitMQ

  • How do I use the RabbitMQ management page

RabbitMQ management commands can be used from the command line as well as the Web management page. VirtualHost in RabbitMQ has several RabbitMQ management commands.

Also in alternative gameplay! The REST API for RabbitMQ was introduced in this article, and it is very convenient to invoke these REST apis in places where it is convenient to send HTTP requests. However, these REST apis are not very convenient for places where sending HTTP requests is inconvenient, so Today Songo will introduce another way of playing RabbitMQ -rabbitmqadmin.

1. rabbitmqadmin

In the production environment, however, there is usually no Web management page and you can only manage MQ using CLI commands.

In fact, although the Web management page is friendly, it is not as fast as the CLI in many cases. Moreover, through the CLI command line operation, we can make more customization, such as finding out the key information and providing it to the centralized monitoring system to trigger the alarm.

RabbitMQ provides the CLI management tool Rabbitmqadmin, which is a Script written in Python based on the RabbitMQ HTTP API. Since the REST API can be cumbersome to write requests manually, these scripts simplify the process and make it much easier.

To use Rabbitmqadmin, install it first.

If we create RabbitMQ containers with RabbitMQ :3-management images, rabbitmqadmin will be installed by default.

Otherwise we may need to install Rabbitmqadmin ourselves, which is very simple,

First, make sure you have Python installed on your device. This is basic, as rabbitmqadmin is a Python script.

Then open the RabbitMQ Web admin page and enter the following address (my admin page is mapped to 25672) :

http://localhost:25672/cli/index.html
Copy the code

The rabbitmqadmin download link is available on the page that opens. Download rabbitmqadmin and grant it executable permissions:

chmod +x rabbitmqadmin
Copy the code

Rabbitmqadmin can be downloaded directly from notepad, which is a bunch of Python scripts.

This process can be quite cumbersome, so I recommend using rabbitMQ :3-management in one step.

2. Rabbitmqadmin functionality

  • List exchanges, queues, Bindings, vhosts, Users, permissions, connections and channels.
  • Create and delete exchanges, queues, Bindings, vhosts, Users and permissions.
  • Publish and get messages, as well as message details.
  • Close the connection and clear the queue.
  • Import and export configurations.

Next, Songko will introduce these functions one by one.

3. List information

View all switches:

rabbitmqadmin list exchanges
Copy the code

View all queues:

rabbitmqadmin list queues
Copy the code

View all bindings:

rabbitmqadmin list bindings
Copy the code

View all virtual hosts:

rabbitmqadmin list vhosts
Copy the code

View all user information:

rabbitmqadmin list users
Copy the code

View all permission information:

rabbitmqadmin list permissions
Copy the code

To view all connection information:

rabbitmqadmin list connections
Copy the code

View information about all channels:

rabbitmqadmin list channels
Copy the code

4. A complete example

Let’s write a complete message sending example using Rabbitmqadmin.

First create a switch called Javaboy-Exchange:

rabbitmqadmin declare exchange name=javaboy-exchange durable=true auto_delete=false type=direct
Copy the code

I don’t want to go into all the parameters here because they’re easy to understand.

Next create a queue named Javaboy-queue: javaboy-queue

rabbitmqadmin declare queue name=javaboy-queue durable=true auto_delete=false
Copy the code

Next create a Binding to bind the switch to the message queue:

rabbitmqadmin declare binding source=javaboy-exchange destination=javaboy-queue routing_key=javaboy-routing
Copy the code

There are three concepts involved:

  • Source: switch.
  • Destination: a message queue.
  • Routing_key: This is the key of the route.

Here’s a message:

rabbitmqadmin publish routing_key=javaboy-queue payload="hello javaboy"
Copy the code

Here the parameters are very simple, there is nothing to say.

View messages in the queue (only view, not consume, messages are still there after viewing) :

rabbitmqadmin get queue=javaboy-queue
Copy the code

Emptying a queue of messages:

rabbitmqadmin purge queue name=javaboy-queue
Copy the code

5. Command Overview

The form font is a little small, please reply rabbitmqadmin to get the Excel document link.

6. Summary

Rabbitmqadmin is a Python script that provides rabbitmqadmin and rabbitmqadmin. Rabbitmqadmin is a Python script that provides rabbitmqadmin and rabbitmqadmin