Skip to content
Latchkey

rabbitmqadmin publish and get: Move Test Messages

rabbitmqadmin publish routing_key=<k> payload=<body> sends a message, and rabbitmqadmin get queue=<q> reads one back, both over the management HTTP API.

For a round-trip smoke test of a RabbitMQ setup, publish then get proves the exchange, binding, and queue all work without writing an AMQP client.

What it does

publish posts a message to the default or a named exchange with a routing key; the management API routes it to bound queues. get retrieves messages from a queue. ackmode controls whether get acknowledges (and removes) the message or requeues it.

Common usage

Terminal
# publish to the default exchange, routed by queue name
rabbitmqadmin publish routing_key=orders payload='{"id":1}'
# publish via a named exchange
rabbitmqadmin publish exchange=events routing_key=order.created payload='hi'
# read a message back without removing it
rabbitmqadmin get queue=orders ackmode=ack_requeue_true

Options

ArgWhat it does
publish routing_key=<k>Routing key for the message
payload=<body>Message body
exchange=<name>Publish via this exchange (default: the default exchange)
get queue=<q>Read messages from this queue
ackmode=ack_requeue_trueRead but leave the message on the queue
ackmode=ack_requeue_falseRead and remove the message
count=<n>Number of messages to get

In CI

publish returns routed: true when at least one queue received the message and routed: false when nothing was bound, which is a cheap assertion that your bindings are correct. Use ackmode=ack_requeue_true when you only want to peek so the message stays for the real consumer.

Common errors in CI

"Access refused for user 'guest'" is a credentials or guest-localhost-only problem. A publish that reports "routed": false means no queue is bound to that routing key; declare the binding first. "Not found" on get means the queue does not exist. Aiming at the AMQP port 5672 instead of 15672 gives a connection or parse error.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →