virtualMachinerabbitmq

Use the RabbitMQ admin console

To use the RabbitMQ admin console, follow these steps:

  • Download the rabbitmqadmin application from http://SERVER-IP:15672/cli/. You will need Python 2.5, 2.6 or later.

  • Copy rabbitmqadmin to /usr/local/bin/ and give it execution permissions.

      $ chmod +x rabbitmqadmin
    
  • Invoke the following for usage instructions:

      $ rabbitmqadmin --help
    

    This command allows you to:

    • 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.

Usage examples

  • To connect to your machine and list the vhosts that there are created:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD list vhosts
    
  • To declare a new user:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare user name=NEW_USER_NAME password=NEW_PASSWORD tags=username
    
  • To give access to the new user:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare permission vhost=/ user=NEW_USER_NAME configure=.* write=.* read=.*
    

    NOTE: You have to specify where the new user can configure, write or write. Use .* to specify all the exchanges in the *vhost*.

  • To delete a user:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD delete user name=NEW_USER_NAME
    
  • To declare an exchange:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare exchange name=NEW_EXCHANGE_NAME type=fanout
    
  • To declare a queue with optional parameters:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD declare queue name=NEW_QUEUE_NAME durable=false
    
  • To publish a message:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD publish exchange=amq.default routing_key=QUEUE_NAME payload="hello, world"
    
  • And to get it back:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD  get queue=QUEUE_NAME requeue=false
    
  • To export a configuration:

      $ rabbitmqadmin -H -u USER_NAME -p PASSWORD export rabbit.config
    
  • To import a configuration:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD -q import rabbit.config
    
  • To close all connections:

      $ rabbitmqadmin -H SERVER-IP -u USER_NAME -p PASSWORD -f tsv -q list connections name | while read conn ; do rabbitmqadmin -q close connection name=${conn} ; done
    
Last modification December 21, 2022