amqp-publish and amqp-consume: rabbitmq-c Tools
amqp-publish -e <exchange> -r <routing-key> and amqp-consume -q <queue> exercise a RabbitMQ broker over the native AMQP protocol on port 5672.
Unlike rabbitmqadmin (HTTP management), the rabbitmq-c amqp-tools speak AMQP itself. They test the real message path a client uses, on the AMQP port, without a JVM or management plugin.
What it does
amqp-publish reads a body from stdin (or --body) and publishes it to an exchange with a routing key over AMQP. amqp-consume subscribes to a queue and runs a command per message (or prints it). Both connect on the AMQP port 5672 using --url or discrete --server/--port flags.
Common usage
# publish a body to the default exchange, routed to a queue name
echo 'hello' | amqp-publish -e "" -r orders \
--url=amqp://guest:guest@localhost:5672/
# consume one message and print it
amqp-consume -q orders --count 1 \
--url=amqp://guest:guest@localhost:5672/ catOptions
| Flag | What it does |
|---|---|
| -e / --exchange <name> | Exchange to publish to ("" = default) |
| -r / --routing-key <key> | Routing key |
| -q / --queue <name> | Queue to consume from |
| --count <n> | Consume n messages then exit (amqp-consume) |
| --url amqp://... | AMQP connection URL (user, pass, host, vhost) |
| --body <text> | Publish this body instead of reading stdin |
In CI
Use --count with amqp-consume so it exits after the expected messages instead of running forever. These tools connect on 5672 (AMQP), unlike rabbitmqadmin on 15672 (HTTP), so they work even when the management plugin is disabled. amqp-consume runs the trailing command per message, so cat just prints bodies.
Common errors in CI
"login failure ... ACCESS_REFUSED" means bad credentials or guest restricted to localhost; use a real user for cross-container CI. "error connecting: Connection refused" means the broker is not up on 5672. "server closed connection ... NOT_FOUND - no queue" from amqp-consume means the queue does not exist; declare it first with rabbitmqadmin or rabbitmqctl.