Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This endpoint is typically at http://<rabbit-server>:<rabbit-port>:/api. The REST API is flexible - it can be used by any client that talks HTTP but is not human friendly. The output is very verbose. Example : This example gets information about the queue called 'q.type1' from the virtual host 'vhMon01'.

Code Block
titleusing rabbit REST API
curl -u $RBT_USER:$RBT_PASSWD http://localhost:15672/api/queues/vhMon01/q.type1

...

Documentation about the REST API is available at 'http://<rabbit-server>:<rabbit-port>/api/index.html'

...

rabbitmqadmin Command Line Tool

The rabbitmqadmin command line tool can be downloaded from each RabbitMQ server that has the 'Management Plugin' installed. It can be downloaded from 'http://<rabbit-server>:<rabbit-port>/cli/rabbitmqadmin'. It talks to the RabbitMQ server using the Rabbit Rest API. The rabbitmqadmin tool requires python as a pre-requisite. The rabbitmqadmin tool can be pointed at a RabbitMQ server on another machine using optional --host and --port parameters. 

It is reasonably straightforward to perform most RabbitMQ configuration tasks using the rabbitmqadmin tool.

...

rabbitmqctl Command Line Tool

The following text is copied from this excellent stackoverflow answer

...

rabbitmqadmin is more for general admin, you have the same features you have in the management UI, you can also retrieve the node statistics.you can also retrieve the node statistics.

rabbitmq-plugins Command Line Tool

One of the limitations of the rabbitmqadmin tool is that you can't use to to check which plugins have been installed. To look at which plugins have been explicitly enabled within RabbitMQ - you have to use the rabbitmq-plugins command which is available on the RabbitMQ server (and not available remotely over http)


Code Block
firstlineShow explicitly enabled RabbitMQ plugins
rabbitmq-plugins list -e
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@d2c02ccab9ce
 |/
[E*] rabbitmq_management       3.7.18
[e*] rabbitmq_management_agent 3.7.18
[e*] rabbitmq_web_dispatch     3.7.18

Overview of RabbitMQ Resources

Most message related resources (queues/exchanges) in RabbitMQ are scoped to a Virtual Host(vhost). A Virtual Host is just a namespace holder. It has a name. The default Virtual Host is named '/'. Virtual Hosts don't have have have a name starting with '/'.

The following resources belong to a Virtual Host (namespace)

  • exchanges Exchanges - where a producer sends messages to
  • queues Queues - where a consumer gets messages from
  • bindings Bindings - these help route messages between exchanges and queues/other exchanges
  • policies Policies - these are useful for "extra" behaviours that can apply to multiple resources in one place - for example when messages are not processed or not routed.

The following resources DO NOT belong to a Virtual Host (vhost)

  • vhosts Vhosts ( they are not hierarchical )
  • users Users - each user can be associated with
    • a password (optional)
    • a list of  Management UI tags - these tags limit what a user can do when logged into Management UI console.
    • three regexp patterns one each for read / write / configure
    • topic permissions (required for MQTT/ STOMP? - not required for TIS)

RabbitMQ ResourcesImage Modified

Using

...

rabbitmqadmin Command Line Tool to configure RabbitMQ

The rabbitmqadmin tool can be used to individually create individual queues/exchanges etc. This works okay but you'd quickly end up with large shell scripts containing lists of separate rabbitmqadmin commands.

...

You can declare(create) and delete vhosts in the management UI. Switch to that virtual host and create the desired RabbitMQ configuration by hand. Within the ManagementUI you can send test messages to the exchanges in your configuration and check that the messages are routed as expected. When you are happy with your configuration, you can export the RabbitMQ Configuration for just for that vhost.

...

A RabbitMQ config file either be associated with a single vhost or all vhosts. If you export a RabbitMQ configuration file for a single vhost - it will not contain any user information. Users do not belong to a specific vhostvhosts. If you export a RabbitMQ configuration file for ALL vhosts - the exported file will contain all the users, all the vhosts and all the permissions linking users to vhosts.

...

When you import a RabbitMQ configutation configuration file into a vhost - it adds to whatever's already there. To reset a vhost to the contents of a config file (and nothing else), best perform the following steps:

  1. delete the vhost - ( be careful - this will delete any messages the vhosts resources and the messages held on the vhosts queues too )
  2. declare (create) the vhost - it will be empty - (expect for the standard amq queues/exchanges)
  3. import the config into the vhost

...

This section shows examples of several rabbitmqadmin commands. To use rabbitmqadmin you need a username/password. Typically each rabbitmq installation will define a single "administrator"A fresh install of RabbitMQ typically comes with an 'admin' user.

The following rabbitmqadmin commands assume the following, pre-defined, environmental variables:

...

Code Block
titleTo show the rabbitmq users' permissions
$ rabbitmqadmin --user=$RBT_USER --password=$RBT_PASSWD list permissions
+---------+-----------+------+--------+-------+
|  vhost  | configure | read |  user  | write |
+---------+-----------+------+--------+-------+
| /       | .*        | .*   | rabbit | .*    |
| vhMon01 | .*        | .*   | rabbit | .*    |
+---------+-----------+------+--------+-------+

Sending a simple message to an

...

Exchange in a vhost

Code Block
titleSending a simple message to an exchange in a vhost
rabbitmqadmin --user=$RBT_USER --password=$RBT_PASSWD --vhost=$VHOST publish routing_key="type1" exchange="ex.topic.01" payload="type1 test message"

Sending a JSON File to an

...

Exchange in a vhost

In the example here, the file 'message01.json' contains json. It seems odd but the rabbitmqadmin command doesn't support sending files.

...