CentOS 8
Sponsored Link

RabbitMQ : Install rabbitmqadmin
2020/04/17
 
It's possible to configure RabbitMQ to use rabbitmqadmin command.
[1] Download [rabbitmqadmin] on Web UI (for how to enable Web UI, refer to here).
Login to Web UI and move to [(hostname or IP address):15672/cli], then following screen is shown, you can download [rabbitmqadmin] on here.
[2] Upload [rabbitmqadmin] to RabbitMQ Server and set suitable permissions.
On this example, it sets like follows.
Furthermore, change python setting like follows.
( install Python 3 first like here )
[root@dlp ~]#
ll /usr/local/bin/rabbitmqadmin

-rwxr-xr-x. 1 root root 40459 Apr 16 20:48 /usr/local/bin/rabbitmqadmin

[root@dlp ~]#
alternatives --config python

There are 2 programs which provide 'python'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/libexec/no-python
   2           /usr/bin/python3

Enter to keep the current selection[+], or type selection number: 2
[3] This is the basic usage for [rabbitmqadmin] command.
# show sub-commands list

# for options list, input [help] only

[root@dlp ~]#
rabbitmqadmin help subcommands

Usage
=====
  rabbitmqadmin [options] subcommand

  where subcommand is one of:

Display
=======

  list connections [<column>...]
.....
.....

# show user list

[root@dlp ~]#
rabbitmqadmin list users

+-------------+--------------------------------+--------------------------------------------------+---------------+
|    name     |       hashing_algorithm        |                  password_hash                   |     tags      |
+-------------+--------------------------------+--------------------------------------------------+---------------+
| guest       | rabbit_password_hashing_sha256 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | administrator |
| serverworld | rabbit_password_hashing_sha256 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | administrator |
+-------------+--------------------------------+--------------------------------------------------+---------------+

# show virtualhost list

[root@dlp ~]#
rabbitmqadmin list vhosts

+-----------+----------+
|   name    | messages |
+-----------+----------+
| /         |          |
| /my_vhost | 2        |
+-----------+----------+

# add user

[root@dlp ~]#
rabbitmqadmin declare user name=redhat password=password tags=administrator

user declared
# add virtualhost

[root@dlp ~]#
rabbitmqadmin declare vhost name=/vhost01

vhost declared
# grant permission

[root@dlp ~]#
rabbitmqadmin declare permission vhost=/vhost01 user=redhat configure=".*" write=".*" read=".*"

permission declared
# add queue

[root@dlp ~]#
rabbitmqadmin -V /vhost01 -u redhat -p password declare queue name=my_queue01

queue declared
# send message

[root@dlp ~]#
rabbitmqadmin -V /vhost01 -u redhat -p password publish routing_key=my_queue01 payload='Hello RabbitMQ World!' exchange=amq.default

Message published
# receive message

[root@dlp ~]#
rabbitmqadmin -V /vhost01 -u redhat -p password get queue=my_queue01

+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+
| routing_key | exchange | message_count |        payload        | payload_bytes | payload_encoding | properties | redelivered |
+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+
| my_queue01  |          | 0             | Hello RabbitMQ World! | 21            | string           |            | False       |
+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+
Matched Content