rabbitmqadmin v2, a Command Line Tool for the HTTP API
rabbitmqadmin v2 is a command line tool that uses the HTTP API.
It supports many of the operations available in the management UI:
- Listing objects (virtual hosts, users, queues, streams, permissions, policies, and so on)
- Creating objects
- Deleting objects
- Access to cluster and node metrics
- Run health checks
- Listing feature flag state
- Listing deprecated features in use across the cluster
- Definition export, transformations, and import
- Operations on shovels
- Operations on federation upstreams and links
- Closing connections
- Rebalancing of queue leaders across cluster nodes
Note that rabbitmqadmin is not a replacement for rabbitmqctl or
rabbitmq-plugins as the HTTP API intentionally doesn't expose certain operations.
rabbitmqadmin v2
This generation of rabbitmqadmin is a standalone project that
has its own development cycle that's independent from that of RabbitMQ.
It is distributed as a native binary.
Downloads
Binaries for x86-64 Linux, aarch64 Linux, aarch64 macOS and x86-64 Windows are distributed via GitHub releases.
Usage
Explore Available Command Groups and Sub-Commands
To explore what command groups are available, use
rabbitmqadmin help
which will output a list of command groups:
Usage: rabbitmqadmin [OPTIONS] <COMMAND>
Commands:
auth_attempts Authentication attempt statistics
bindings Operations on bindings
channels Operations on channels
close Closes connections
config_file Operations on the local configuration file
connections Operations on connections
declare Creates or declares objects
definitions Operations on definitions (everything except for messages: virtual hosts, queues, streams, exchanges, bindings, users, etc)
delete Deletes objects
deprecated_features Operations on deprecated features
exchanges Operations on exchanges
export See 'definitions export'
feature_flags Operations on feature flags
federation Operations on federation upstreams and links
global_parameters Operations on global runtime parameters
health_check Runs health checks
import See 'definitions import'
list Lists objects
nodes Node operations
operator_policies Operations on operator policies
parameters Operations on runtime parameters
passwords Operations on passwords
permissions Operations on user permissions
plugins List enabled plugins
policies Operations on policies
purge Purges queues
queues Operations on queues
rebalance Rebalancing of leader replicas
show Overview, memory footprint breakdown, and more
shovels Operations on shovels
streams Operations on streams
tanzu Tanzu RabbitMQ-specific commands
users Operations on users
user_limits Operations on per-user (resource) limits
vhosts Virtual host operations
vhost_limits Operations on virtual host (resource) limits
help Print this message or the help of the given subcommand(s)
To explore commands in a specific group, use
rabbitmqadmin {group name} help
Explore the CLI with help, --help
To learn about what command groups and specific commands are available, run
rabbitmqadmin help
This flag can be appended to a command or subcommand to get command-specific documentation:
rabbitmqadmin queues declare --help
# => creates or declares things
# =>
# => Usage: rabbitmqadmin declare [object]
# => ...
Alternatively, the help subcommand can be given a command name. It's the equivalent
of tagging on --help at the end of command name:
rabbitmqadmin queues help declare
# => creates or declares things
# =>
# => Usage: rabbitmqadmin declare [object]
# => ...
More specific examples are covered in the Examples section below.
Interactive vs. Use in Scripts
Like the original version, rabbitmqadmin v2 is first and foremost built for interactive use
by humans. Many commands will output formatted tables, for example:
rabbitmqadmin show overview
will output a table that looks like this:
┌───────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Overview │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ key │ value │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Product name │ RabbitMQ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Product version │ 4.1.4 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ RabbitMQ version │ 4.1.4 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Erlang version │ 27.3.4 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Erlang details │ Erlang/OTP 27 [erts-15.2.7] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Connections (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ AMQP 0-9-1 channels (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Queues and streams (total) │ 1 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Consumers (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Messages (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Messages ready for delivery (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Messages delivered but unacknowledged by consumers (total) │ 0 │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Publishing (ingress) rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Publishing confirm rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Consumer delivery (egress) rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Consumer delivery in automatic acknowledgement mode rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Consumer acknowledgement rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Unroutable messages: returned-to-publisher rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Unroutable messages: dropped rate (global) │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Cluster tags │ "core": "8" │
│ │ "env": "development" │
│ │ "machine": "X8Y33L97DQ" │
│ │ │
├───────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Node tags │ "environment": "production" │
│ │ "purpose": "iot_ingress" │
│ │ "region": "ca-central-1" │
│ │ "series": "4.1.x" │
│ │ │
└───────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘
As it is easy to observe, parsing such output in a script will be challenging.
For this reason, rabbitmqadmin v2 can render results in a way that would be much more friendly
for scripting if the --non-interactive flag is passed. It is a global flag so it must be
passed before the command and subcommand name:
rabbitmqadmin --non-interactive show overview
The output of the above command will not include any table borders and will is much easier to parse as a result:
key
Product name RabbitMQ
Product version 4.1.4
RabbitMQ version 4.1.4
Erlang version 27.3.4
Erlang details Erlang/OTP 27 [erts-15.2.7] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Retrieve Basic Node Information
rabbitmqadmin show overview
will display essential node information in tabular form.
Retrieve Connection, Queue/Stream, Channel Churn Information
Helps assess connection, queue/stream, channel churn metrics in the cluster.
rabbitmqadmin show churn
List Cluster Nodes
rabbitmqadmin nodes list
List Virtual Hosts
rabbitmqadmin vhosts list
List Users
rabbitmqadmin users list
Create a User
rabbitmqadmin users declare --name "a-user" --password "secure-password" --tags "monitoring,policymaker"
# Create user with password hash (recommended)
# Use 'rabbitmqadmin passwords salt_and_hash "my-password"' to generate the hash
rabbitmqadmin users declare --name "a-user" --password-hash "$2b$12$abcdefghijklmnopqrstuvwxyz" --tags "administrator"
Delete a User
rabbitmqadmin users delete --name "a-user"
# Idempotent deletion (does not fail if the user doesn't exist)
rabbitmqadmin users delete --name "a-user" --idempotently
List User Permissions
See the Access Control guide for more information on permissions.
# List permissions for all users
rabbitmqadmin users permissions
Grant User Permissions
See the Access Control guide for more information on granting permissions.
# Grant permissions to a user for a virtual host
rabbitmqadmin --vhost "events" declare permissions --user "a-user" --configure ".*" --read ".*" --write ".*"
# Grant limited permissions (read-only for specific queues)
rabbitmqadmin --vhost "events" declare permissions --user "monitoring" --configure "" --read "^metrics\\..*" --write ""
Revoke User Permissions
See the Access Control guide for more information on permissions.
# Revoke all permissions for a user in a virtual host
rabbitmqadmin --vhost "events" delete permissions --user "a-user"
# Idempotent revocation (does not fail if permissions don't exist)
rabbitmqadmin --vhost "events" delete permissions --user "a-user" --idempotently
List User Connections
# List connections for a specific user
rabbitmqadmin users connections --username "a-user"
List Queues
rabbitmqadmin queues list
rabbitmqadmin --vhost "monitoring" queues list
List Exchanges
rabbitmqadmin exchanges list
rabbitmqadmin --vhost "events" exchanges list
List Bindings
rabbitmqadmin bindings list
rabbitmqadmin --vhost "events" bindings list
Bind a Queue to an Exchange
rabbitmqadmin --vhost "events" bindings declare --source "events.topic" --destination-type "queue" --destination "target.queue" --routing-key "events.order.created"
Bind a Source Exchange to a Destination Exchange
rabbitmqadmin --vhost "events" bindings declare --source "events.topic" --destination-type "exchange" --destination "events.fanout" --routing-key "events.*"
Delete a Binding
rabbitmqadmin --vhost "events" bindings delete --source "events.topic" --destination-type "queue" --destination "target.queue" --routing-key "events.order.created"
Bind an Exchange to a Queue or Another Exchange
The exchanges bind command is an alternative to bindings declare:
rabbitmqadmin --vhost "events" exchanges bind --source "events.topic" --destination-type "queue" --destination "events.processing" --routing-key "user.created"
rabbitmqadmin --vhost "events" exchanges bind --source "events.fanout" --destination-type "exchange" --destination "events.archived" --routing-key ""
Unbind an Exchange from a Queue or Another Exchange
The exchanges unbind command is an alternative to bindings delete:
rabbitmqadmin --vhost "events" exchanges unbind --source "events.topic" --destination-type "queue" --destination "events.processing" --routing-key "user.created"
rabbitmqadmin --vhost "events" exchanges unbind --source "events.fanout" --destination-type "exchange" --destination "events.archived" --routing-key ""
Create a Virtual Host
rabbitmqadmin vhosts declare --name "vh-789" --default-queue-type "quorum" --description "Used to reproduce issue #789"
Delete a Virtual Host
rabbitmqadmin vhosts delete --name "vh-789"
# --idempotently means that 404 Not Found responses will not be considered errors
rabbitmqadmin vhosts delete --name "vh-789" --idempotently
Delete Multiple Virtual Hosts
THIS IS AN EXTREMELY DESTRUCTIVE OPERATION AND MUST BE USED WITH EXTREME CARE.
This command will delete ALL virtual hosts matching the provided regular expression pattern. ALL data in those virtual hosts will be permanently lost, including:
- Queues, streams, and partitioned streams
- Exchanges and bindings
- Messages
- User permissions
- Federation upstreams and links
- Shovels
- Policies and operator policies
- Runtime parameters
ALWAYS use --dry-run first to verify what will be deleted before running the actual deletion.
# ALWAYS run with --dry-run first to see what would be deleted
rabbitmqadmin vhosts delete_multiple --name-pattern "^test-.*" --dry-run
# After verifying with --dry-run, use --approve to perform the actual deletion
# This will delete ALL virtual hosts whose names start with "test-"
rabbitmqadmin vhosts delete_multiple --name-pattern "^test-.*" --approve
The default virtual host (/) is always preserved and will never be deleted by this command, even if it matches the pattern.
Enable Virtual Host Deletion Protection
Virtual host deletion protection prevents a virtual host from being accidentally deleted. This is useful for protecting critical production virtual hosts.
See the Virtual Hosts guide for more information on deletion protection.
rabbitmqadmin vhosts enable_deletion_protection --name "production"
# Enable deletion protection for multiple critical virtual hosts
rabbitmqadmin vhosts enable_deletion_protection --name "production"
rabbitmqadmin vhosts enable_deletion_protection --name "staging"
Disable Virtual Host Deletion Protection
See the Virtual Hosts guide for more information on deletion protection.
rabbitmqadmin vhosts disable_deletion_protection --name "production"
List Virtual Host Limits
# List limits for all virtual hosts
rabbitmqadmin list vhost_limits
# List limits for a specific virtual host
rabbitmqadmin --vhost "events" list vhost_limits
Set a Virtual Host Limit
# Set a limit on maximum number of connections
rabbitmqadmin --vhost "events" declare vhost_limit --name "max-connections" --value 100
# Set a limit on maximum number of queues
rabbitmqadmin --vhost "events" declare vhost_limit --name "max-queues" --value 500
Delete a Virtual Host Limit
rabbitmqadmin --vhost "events" delete vhost_limit --name "max-connections"
List User Limits
# List limits for a specific user
rabbitmqadmin list user_limits --user "a-user"
Set a User Limit
# Set a limit on maximum number of connections for a user
rabbitmqadmin declare user_limit --user "a-user" --name "max-connections" --value 10
# Set a limit on maximum number of channels for a user
rabbitmqadmin declare user_limit --user "a-user" --name "max-channels" --value 50
Delete a User Limit
rabbitmqadmin delete user_limit --user "a-user" --name "max-connections"
Declare a Queue
rabbitmqadmin --vhost "events" queues declare --name "target.quorum.queue.name" --type "quorum" --durable true
rabbitmqadmin --vhost "events" queues declare --name "target.stream.name" --type "stream" --durable true
rabbitmqadmin --vhost "events" queues declare --name "target.classic.queue.name" --type "classic" --durable true --auto-delete false
List Streams
rabbitmqadmin streams list
# List streams in a specific virtual host
rabbitmqadmin --vhost "events" streams list
Declare a Stream
rabbitmqadmin --vhost "events" streams declare --name "events.stream" --expiration "3D"
Delete a Stream
rabbitmqadmin --vhost "events" streams delete --name "events.stream"
Show Stream Details
rabbitmqadmin --vhost "events" streams show --name "events.stream"
# Show only specific columns
rabbitmqadmin --vhost "events" streams show --name "events.stream" --columns "name,messages,consumers"
Purge a Queue
rabbitmqadmin --vhost "events" queues purge --name "target.queue.name"
Delete a Queue
rabbitmqadmin --vhost "events" queues delete --name "target.queue.name"
# --idempotently means that 404 Not Found responses will not be considered errors
rabbitmqadmin --vhost "events" queues delete --name "target.queue.name" --idempotently
Show Queue Details
rabbitmqadmin --vhost "events" queues show --name "target.queue.name"
# Show only specific columns
rabbitmqadmin --vhost "events" queues show --name "target.queue.name" --columns "name,type,messages,consumers"
Declare an Exchange
rabbitmqadmin --vhost "events" exchanges declare --name "events.all_types.topic" --type "topic" --durable true
rabbitmqadmin --vhost "events" exchanges declare --name "events.all_type.uncategorized" --type "fanout" --durable true --auto-delete false
rabbitmqadmin --vhost "events" exchanges declare --name "local.random.c60bda92" --type "x-local-random" --durable true
Delete an Exchange
rabbitmqadmin --vhost "events" exchanges delete --name "target.exchange.name"
# --idempotently means that 404 Not Found responses will not be considered errors
rabbitmqadmin --vhost "events" exchanges delete --name "target.exchange.name" --idempotently
List Connections
rabbitmqadmin connections list
# List connections for a specific virtual host
rabbitmqadmin --vhost "events" connections list
Close a Connection
rabbitmqadmin connections close --name "127.0.0.1:5672 -> 127.0.0.1:59876"
Close All Connections for a User
rabbitmqadmin users close_connections --name "a-user"
List Channels
rabbitmqadmin channels list
# List channels in a specific virtual host
rabbitmqadmin --vhost "events" channels list
List Consumers
rabbitmqadmin consumers list
# List consumers in a specific virtual host
rabbitmqadmin --vhost "events" consumers list
Bind an Exchange to a Queue
rabbitmqadmin --vhost "events" exchanges bind --source "events.topic" --destination-type "queue" --destination "target.queue" --routing-key "events.*"
Bind an Exchange to Another Exchange
rabbitmqadmin --vhost "events" exchanges bind --source "events.topic" --destination-type "exchange" --destination "events.fanout" --routing-key "events.*"
Unbind an Exchange from a Queue
rabbitmqadmin --vhost "events" exchanges unbind --source "events.topic" --destination-type "queue" --destination "target.queue" --routing-key "events.*"
Unbind an Exchange from Another Exchange
rabbitmqadmin --vhost "events" exchanges unbind --source "events.topic" --destination-type "exchange" --destination "events.fanout" --routing-key "events.*"
Inspect Node Memory Breakdown
There are two commands for reasoning about target node's memory footprint:
# displays a breakdown in bytes
rabbitmqadmin show memory_breakdown_in_bytes --node 'rabbit@hostname'
# displays a breakdown in percent
rabbitmqadmin show memory_breakdown_in_percent --node 'rabbit@hostname'
Example output of show memory_breakdown_in_percent:
┌────────────────────────────────────────┬────────────┐
│ key │ percentage │
├────────────────────────────────────────┼────────────┤
│ total │ 100% │
├────────────────────────────────────────┼────────────┤
│ Binary heap │ 45.10% │
├────────────────────────────────────────┼────────────┤
│ Allocated but unused │ 23.45% │
├────────────────────────────────────────┼────────────┤
│ Quorum queue ETS tables │ 23.05% │
├────────────────────────────────────────┼────────────┤
│ Other processes │ 5.32% │
├────────────────────────────────────────┼────────────┤
│ Other (used by the runtime) │ 4.98% │
├────────────────────────────────────────┼────────────┤
│ Code │ 4.54% │
├────────────────────────────────────────┼────────────┤
│ Client connections: others processes │ 3.64% │
├────────────────────────────────────────┼────────────┤
│ Management stats database │ 3.48% │
├────────────────────────────────────────┼────────────┤
│ Client connections: reader processes │ 3.22% │
├────────────────────────────────────────┼────────────┤
│ Plugins and their data │ 3.12% │
├────────────────────────────────────────┼────────────┤
│ Other (ETS tables) │ 1.55% │
├────────────────────────────────────────┼────────────┤
│ Metrics data │ 0.66% │
├────────────────────────────────────────┼────────────┤
│ AMQP 0-9-1 channels │ 0.40% │
├────────────────────────────────────────┼────────────┤
│ Message store indices │ 0.27% │
├────────────────────────────────────────┼────────────┤
│ Atom table │ 0.24% │
├────────────────────────────────────────┼────────────┤
│ Client connections: writer processes │ 0.19% │
├────────────────────────────────────────┼────────────┤
│ Quorum queue replica processes │ 0.10% │
├────────────────────────────────────────┼────────────┤
│ Stream replica processes │ 0.07% │
├────────────────────────────────────────┼────────────┤
│ Mnesia │ 0.02% │
├────────────────────────────────────────┼────────────┤
│ Metadata store │ 0.02% │
├────────────────────────────────────────┼────────────┤
│ Stream coordinator processes │ 0.02% │
├────────────────────────────────────────┼────────────┤
│ Classic queue processes │ 0.00% │
├────────────────────────────────────────┼────────────┤
│ Metadata store ETS tables │ 0.00% │
├────────────────────────────────────────┼────────────┤
│ Stream replica reader processes │ 0.00% │
├────────────────────────────────────────┼────────────┤
│ Reserved by the kernel but unallocated │ 0.00% │
└────────────────────────────────────────┴────────────┘
Note that there are two different supported strategies
for computing memory footprint of a node. rabbitmqadmin will use the greater value
for 100% when computing the relative share in percent for each category.
Other factors that can affect the precision of percentage values reported are runtime allocator behavior nuances and the kernel page cache.
An alternative way to access memory breakdown is via the nodes command group:
rabbitmqadmin nodes memory_breakdown_in_bytes --node 'rabbit@hostname'
rabbitmqadmin nodes memory_breakdown_in_percent --node 'rabbit@hostname'
List Feature Flags and Their State
rabbitmqadmin feature_flags list
Enable a Feature Flag
rabbitmqadmin feature_flags enable --name rabbitmq_4.0.0
Enable All Stable Feature Flags
rabbitmqadmin feature_flags enable_all
List Deprecated Features in Use in the Cluster
rabbitmqadmin deprecated_features list_used
List All Deprecated Features
rabbitmqadmin deprecated_features list
Export Definitions
To export definitions to standard output, use definitions export --stdout:
rabbitmqadmin definitions export --stdout
To export definitions to a file, use definitions export --file /path/to/definitions.file.json:
rabbitmqadmin definitions export --file /path/to/definitions.file.json
Export and Transform Definitions
definitions export can transform the exported JSON definitions file it gets from the
target node. This is done by applying one or more transformations to the exported
JSON file.
This can be useful to remove classic queue mirroring-related keys (such as ha-mode) from a definitions
set originating from a 3.13.x node, or to obfuscate usernames and passwords, or exclude certain definitions file
sections entirely.
To specify what transformations should be applied, use the --transformations options,
which takes a comma-separated list of supported operation names.
The following table explains what transformations are available and what they do:
| Transformation name | Description |
|---|---|
strip_cmq_keys_from_policies | Deletes all classic queue mirroring-related keys (such as ha-mode) from all exported policies.Must be followed by drop_empty_policies to strip off the policies whose definition has become empty (and thus invalid at import time) after the removal of all classic queue mirroring-related keys |
drop_empty_policies | Should be used after strip_cmq_keys_from_policies to strip off the policies whose definition has become empty (and thus invalid at import time) after the removal of all classic queue mirroring-related keys |
obfuscate_usernames | Replaces usernames and passwords with dummy values. For usernames the values used are: obfuscated-username-1, obfuscated-username-2, and so on.For passwords the values generated are: password-1, password-2, and so forth.This transformations updates both the users and the permissions sections, consistently |
exclude_users | Removes all users from the result. Commonly used together with exclude_permissions |
exclude_permissions | Removes all permissions from the result. Commonly used together with exclude_users |
exclude_runtime_parameters | Removes all runtime parameters (including federation upstreams, shovels, WSR and SDS settings in Tanzu RabbitMQ) from the result |
exclude_policies | Removes all policies from the result |
no_op | Does nothing. Can be used as the default in dynamically computed transformation lists, e.g. in scripts |
The following command applies two transformations named strip_cmq_keys_from_policies and drop_empty_policies
that will strip all classic queue mirroring-related policy keys that RabbitMQ 3.13 nodes supported,
then removes the policies that did not have any keys left (ended up having an empty definition):
# strips classic mirrored queue-related policy keys from the exported definitions, then prints them
# to the standard output stream
rabbitmqadmin definitions export --stdout --transformations strip_cmq_keys_from_policies,drop_empty_policies
The following example exports definitions without users and permissions:
# removes users and user permissions from the exported definitions, then prints them
# to the standard output stream
rabbitmqadmin definitions export --stdout --transformations exclude_users,exclude_permissions
To export definitions with usernames replaced by dummy values (usernames: obfuscated-username-1, obfuscated-username-2, and so on;
passwords: password-1, password-2, and so forth), use the obfuscate_usernames transformation:
rabbitmqadmin definitions export --file /path/to/definitions.file.json --transformations obfuscate_usernames
Import Definition
To import definitions from the standard input, use definitions import --stdin:
cat /path/to/definitions.file.json | rabbitmqadmin definitions import --stdin
To import definitions from a file, use definitions import --file /path/to/definitions.file.json:
rabbitmqadmin definitions import --file /path/to/definitions.file.json
Export Definitions from a Virtual Host
To export definitions from a specific virtual host:
rabbitmqadmin --vhost "events" definitions export_from_vhost --stdout
rabbitmqadmin --vhost "events" definitions export_from_vhost --file /path/to/vhost-definitions.json
Import Virtual Host-specific Definitions
To import definitions into a specific virtual host:
rabbitmqadmin --vhost "events" definitions import_into_vhost --file /path/to/vhost-definitions.json
Declare an AMQP 0-9-1 Shovel
To declare a dynamic shovel that uses AMQP 0-9-1 for both source and destination, use
shovels declare_amqp091:
rabbitmqadmin shovels declare_amqp091 --name my-amqp091-shovel \
--source-uri amqp://username:s3KrE7@source.hostname:5672 \
--destination-uri amqp://username:s3KrE7@source.hostname:5672 \
--ack-mode "on-confirm" \
--source-queue "src.queue" \
--destination-queue "dest.queue"
# When source and destination queues already exist (predeclared topology)
rabbitmqadmin shovels declare_amqp091 --name my-amqp091-shovel \
--source-uri amqp://username:s3KrE7@source.hostname:5672 \
--destination-uri amqp://username:s3KrE7@source.hostname:5672 \
--ack-mode "on-confirm" \
--source-queue "src.queue" \
--destination-queue "dest.queue" \
--predeclared-source \
--predeclared-destination
Declare an AMQP 1.0 Shovel
To declare a dynamic shovel that uses AMQP 1.0 for both source and destination, use
shovels declare_amqp10.
Note that
- With AMQP 1.0 shovels, credentials in the URI are mandatory (there are no defaults)
- With AMQP 1.0 shovels, the topology must be pre-declared (an equivalent of
--predeclared-sourceand--predeclared-destinationflags for AMQP 0-9-1 shovels) - AMQP 1.0 shovels should use AMQP 1.0 addresses v2
rabbitmqadmin shovels declare_amqp10 --name my-amqp1.0-shovel \
--source-uri "amqp://username:s3KrE7@source.hostname:5672?hostname=vhost:src-vhost" \
--destination-uri "amqp://username:s3KrE7@source.hostname:5672?hostname=vhost:dest-vhost" \
--ack-mode "on-confirm" \
--source-address "/queues/src.queue" \
--destination-address "/queues/dest.queue"
List Shovels
To list shovels across all virtual hosts, use shovels list_all:
rabbitmqadmin shovels list_all
List Shovels in a Virtual Host
rabbitmqadmin --vhost "events" shovels list
Delete a Shovel
To delete a shovel, use shovels delete --name:
rabbitmqadmin shovels delete --name my-amqp091-shovel
Manage TLS Peer Verification for Shovels
These commands should only be used in emergency situations. Disabling TLS peer verification reduces security. Always prefer enabling verification with proper certificates.
# Disable TLS peer verification for all shovel source URIs (emergency use only)
rabbitmqadmin --vhost "events" shovels disable_tls_peer_verification_for_all_source_uris
# Disable TLS peer verification for all shovel destination URIs (emergency use only)
rabbitmqadmin --vhost "events" shovels disable_tls_peer_verification_for_all_destination_uris
# Enable TLS peer verification for all shovel source URIs with certificate paths
# Note: paths must be accessible on the RabbitMQ node(s), not the local machine
rabbitmqadmin --vhost "events" shovels enable_tls_peer_verification_for_all_source_uris \
--node-local-ca-certificate-bundle-path /etc/rabbitmq/certs/ca-bundle.pem \
--node-local-client-certificate-file-path /etc/rabbitmq/certs/client-cert.pem \
--node-local-client-private-key-file-path /etc/rabbitmq/certs/client-key.pem
# Enable TLS peer verification for all shovel destination URIs with certificate paths
rabbitmqadmin --vhost "events" shovels enable_tls_peer_verification_for_all_destination_uris \
--node-local-ca-certificate-bundle-path /etc/rabbitmq/certs/ca-bundle.pem \
--node-local-client-certificate-file-path /etc/rabbitmq/certs/client-cert.pem \
--node-local-client-private-key-file-path /etc/rabbitmq/certs/client-key.pem
List Federation Upstreams
To list federation upstreams across all virtual hosts, use federation list_all_upstreams:
rabbitmqadmin federation list_all_upstreams
Create a Federation Upstream for Exchange Federation
To create a federation upstream, use federation declare_upstream_for_exchanges.
This command provides a reduced set of options, only those that are relevant
specifically to exchange federation.
rabbitmqadmin --vhost "local-vhost" federation declare_upstream_for_exchanges --name "pollux" \
--uri "amqp://pollux.eng.megacorp.local:5672/remote-vhost" \
--ack-mode 'on-publish' \
--prefetch-count 2000 \
--exchange-name "overridden.name" \
--queue-type quorum \
--bind-using-nowait true
Create a Federation Upstream for Queue Federation
To create a