CentOS 7
Sponsored Link

RabbitMQ : Use rabbitmqadmin2016/09/03

 
It's possible to configure RabbitMQ to use rabbitmqadmin command.
[1] Download rabbitmqadmin on Web UI.
Login to Web UI and move to "http://(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.
This example shows to set it like follows.
[root@dlp ~]#
ll /usr/local/bin/rabbitmqadmin

-rwxr-xr-x. 1 root root 32406 Sep 5 19:12 /usr/local/bin/rabbitmqadmin
[3] Basic operations with rabbitmqadmin command.
# show sub-commands list

# for options list, input "help" only

[root@dlp ~]#
rabbitmqadmin help subcommands

Usage
=====
  rabbitmqadmin [options] subcommand
.....
.....

# show user list

[root@dlp ~]#
rabbitmqadmin list users

+-------------+------------------------------+---------------+
|    name     |        password_hash         |     tags      |
+-------------+------------------------------+---------------+
| guest       | xxxxxxxxxxxxxxxxxxxxxxxxxxxx | administrator |
| serverworld | xxxxxxxxxxxxxxxxxxxxxxxxxxxx | administrator |
+-------------+------------------------------+---------------+

# show virtualhost list

[root@dlp ~]#
rabbitmqadmin list vhosts

+-----------+----------+----------------+-------------------------+----------+----------+---------+
|   name    | messages | messages_ready | messages_unacknowledged | recv_oct | send_oct | tracing |
+-----------+----------+----------------+-------------------------+----------+----------+---------+
| /         |          |                |                         |          |          | False   |
| /my_vhost | 2        | 2              | 0                       | 748      | 1004     | False   |
+-----------+----------+----------------+-------------------------+----------+----------+---------+

# add user

[root@dlp ~]#
rabbitmqadmin declare user name=centos 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=centos configure=".*" write=".*" read=".*"

permission declared
# add queue

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

queue declared
# send message

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

Message published
# receive message

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

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