skip to content
Alvin Lucillo

Basic rabbitmq process

/ 1 min read

Quick demo of rabbitmq with existing tools just to see it in action.

  1. Run a rabbitmq container so you won’t have to install it on the local machine: docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4-management
  2. Download rabbmitmqadmin from your local instance: wget http://localhost:15672/cli/rabbitmqadmin
  3. Make the tool executable: chmod +x ./rabbitmqadmin
  4. Check the queue
./rabbitmqadmin list queues
No items
  1. Declare a queue
 ./rabbitmqadmin declare queue name=greetings durable=true
queue declared
  1. Publish a message
./rabbitmqadmin publish exchange=amq.default routing_key=greetings payload="Hello, World"
Message published
  1. Check the queue again
./rabbitmqadmin list queues
+-----------+----------+
|   name    | messages |
+-----------+----------+
| greetings | 1        |
+-----------+----------+
  1. Get the message
./rabbitmqadmin get queue=greetings
+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+
| routing_key | exchange | message_count |   payload    | payload_bytes | payload_encoding | properties | redelivered |
+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+
| greetings   |          | 0             | Hello, World | 12            | string           |            | False       |
+-------------+----------+---------------+--------------+---------------+------------------+------------+-------------+