Skip to main content
Version: Next

Management Command Line Tool

The management plugin ships with a command line tool rabbitmqadmin which can perform some of the same actions as the Web-based UI, and which may be more convenient for automation tasks. Note that rabbitmqadmin is just a specialised HTTP client; if you are contemplating invoking rabbitmqadmin from your own program you may want to consider using an HTTP API client library instead.

Note that rabbitmqadmin is not a replacement for rabbitmqctl or rabbitmq-plugins. HTTP API intentionally doesn't expose certain operations.

Obtaining rabbitmqadmin

rabbitmqadmin can be downloaded from any RabbitMQ node that has the management plugin enabled. Navigate to http://{hostname}:15672/cli/rabbitmqadmin to download it. The tool requires a supported version of Python to be installed.

Alternatively, rabbitmqadmin can be downloaded from GitHub.

Getting Started

UNIX-like operating system users need to copy rabbitmqadmin to a directory in PATH, e.g. /usr/local/bin.

Windows users will need to ensure Python is on their PATH, and invoke rabbitmqadmin as python.exe rabbitmqadmin.

Invoke rabbitmqadmin --help for usage instructions. You can:

  • list exchanges, queues, bindings, vhosts, users, permissions, connections and channels
  • show overview information
  • declare and delete exchanges, queues, bindings, vhosts, users and permissions
  • publish and get messages
  • close connections and purge queues
  • import and export configuration

For other tasks, see rabbitmqctl and rabbitmq-plugins.

rabbitmqadmin and RabbitMQ HTTP API Compatibility

rabbitmqadmin is developed in lock step with the management plugin and thus targets a specific version of the HTTP API. For most operations, rabbitmqadmin can used against any reasonably recent RabbitMQ version. However, there are exceptions to this rule.

rabbitmqadmin therefore requires the same version series as its target RabbitMQ nodes. For example, rabbitmqadmin 3.7.x can only be used against RabbitMQ 3.7.x nodes, 3.6.x against RabbitMQ 3.6.x nodes, and so on.

bash completion

rabbitmqadmin supports tab completion in bash. To print a bash completion script, invoke rabbitmqadmin --bash-completion. This should be redirected to a file and sourced.

On Debian-derived systems, copy the file to /etc/bash_completion.d to make it available system-wide:

sudo sh -c 'rabbitmqadmin --bash-completion > /etc/bash_completion.d/rabbitmqadmin'

Examples

Get a list of exchanges

rabbitmqadmin -V test list exchanges
# => +-------------+---------+-------+---------+-------------+
# => | name | durable | vhost | type | auto_delete |
# => +-------------+---------+-------+---------+-------------+
# => | | True | test | direct | False |
# => | amq.direct | True | test | direct | False |
# => | amq.fanout | True | test | fanout | False |
# => | amq.headers | True | test | headers | False |
# => | amq.match | True | test | headers | False |
# => | amq.topic | True | test | topic | False |
# => +-------------+---------+-------+---------+-------------+

Get a list of queues, with some columns specified

rabbitmqadmin list queues vhost name node messages message_stats.publish_details.rate
# => +-------+----------------------------------+-------------------+----------+------------------------------------+
# => | vhost | name | node | messages | message_stats.publish_details.rate |
# => +-------+----------------------------------+-------------------+----------+------------------------------------+
# => | / | amq.gen-UELtxwb8OGJ9XHlHJq0Jug== | rabbit@smacmullen | 0 | 100.985821591 |
# => | / | test | rabbit@misstiny | 5052 | 100.985821591 |
# => +-------+----------------------------------+-------------------+----------+------------------------------------+

Get a list of queues, with all the detail we can take

rabbitmqadmin -f long -d 3 list queues
# => --------------------------------------------------------------------------------
# =>
# => vhost: /
# => name: amq.gen-UELtxwb8OGJ9XHlHJq0Jug==
# => auto_delete: False
# => backing_queue_status.avg_ack_egress_rate: 100.944672225
# => backing_queue_status.avg_ack_ingress_rate: 100.944672225
# => ...

Connect to another host as another user

rabbitmqadmin -H myserver -u simon -p simon list vhosts
# => +------+
# => | name |
# => +------+
# => | / |
# => +------+

Declare an exchange

rabbitmqadmin declare exchange name=my-new-exchange type=fanout
# => exchange declared

Declare a queue, with optional parameters

rabbitmqadmin declare queue name=my-new-queue durable=false
# => queue declared

Publish a message

rabbitmqadmin publish exchange=amq.default routing_key=test payload="hello, world"
# => Message published

And get it back

rabbitmqadmin get queue=test ackmode=ack_requeue_false
# => +-------------+----------+---------------+--------------+------------------+-------------+
# => | routing_key | exchange | message_count | payload | payload_encoding | redelivered |
# => +-------------+----------+---------------+--------------+------------------+-------------+
# => | test | | 0 | hello, world | string | False |
# => +-------------+----------+---------------+--------------+------------------+-------------+

Export Configuration (Definitions)

rabbitmqadmin export rabbit.definitions.json
# => Exported configuration for localhost to "rabbit.config"

Import Configuration (Definitions), quietly

rabbitmqadmin -q import rabbit.definitions.json

Close all connections

rabbitmqadmin -f tsv -q list connections name | while read conn ; do rabbitmqadmin -q close connection name="${conn}" ; done