<- Back

rabbitmq

Exchanges
Declare
rabbitmqadmin declare exchange name=my-exchange type=topic durable=true
List
rabbitmqadmin list exchanges
Queues
Declare
rabbitmqadmin declare queue name=my-queue durable=true
Declare with DLX
rabbitmqadmin declare queue name=my-queue-with-dlx durable=true arguments="{\"x-dead-letter-exchange\":\"dead-letter-exchange\"}"
Declare quorum queue
rabbitmqadmin declare queue name=my-quorum-queue queue_type=quorum durable=true arguments="{\"x-dead-letter-exchange\":\"dead-letter-exchange\",\"x-delivery-limit\":3}"
List
rabbitmqadmin list queues
Bindings
Bind exchange to queue
rabbitmqadmin declare binding source="my-exchange" destination_type="queue" destination="my-queue" routing_key="*"
Messages
Publish
rabbitmqadmin publish exchange=my-exchange routing_key=my-routing-key properties="{\"delivery_mode\":2}" payload='test'
Get
rabbitmqadmin get queue=my-queue ackmode=ack_requeue_true --depth=4
Docker
run
docker run -it --name rabbitmq --rm -p 5672:5672 -p 15672:15672 rabbitmq:3.8-management
rabbitmqadmin
docker exec -it rabbitmq rabbitmqadmin list exchanges
Plugins
list
rabbitmq-plugins list
enable
rabbitmq-plugins enable rabbitmq_shovel rabbitmq_shovel_management

durable queues and exchanges survive a restart.

delivery_mode 2 means persistent message. It only works with durable queues.

Possible values for ackmode:

ackmode Description
ack_requeue_true Nack message requeue true
ack_requeue_false Automatic ack
reject_requeue_true Reject requeue true
reject_requeue_false Reject requeue false

--depth is needed to display message headers.