
A shovel is used to move a message from a queue or exchange to a different queue or exchage. The queues or exchanges can reside on the same RabbitMQ node or on different RabbitMQ nodes.
AVOID TROUBLE
Before you can create a shovel, the rabbitmq_shovel plugin will need to be enabled, and you may want to also enable the rabbitmq_shovel_management plugin so that you can use Shovel Status and Shovel Management in the RabbitMQ web browser console and the RabbitMQ REST API to list/create/delete dynamic shovels. The rabbitmq-plugins list command can be used to determine if the plugins are enabled. If not, the rabbitmq-plugins enable command can be used to enable the plugins.
If the RabbitMQ node is not using SSL, the src-uri or dest-uri should start with amqp://. If SSL is being used, the src-uri or dest-uri should start with amqps://.
There are two types of shovels.
- Dynamic - Created using the rabbitmqctl set_parameter command, or using the RabbitMQ REST API, or using the RabbitMQ web browser console, or using Terraform
- Static - defined in advanced.config, node must be restarted to create/delete a static shovel
Here is an example of how you could use the rabbitmqctl command with the shovel_status option to return the status of each shovel.
rabbitmqctl shovel_status
Something like this should be returned.
Shovel status on node rabbit@server001
destination destination_protocol destination_queue last_changed name source
source_exchange source_exchange_key source_protocol state termination_reason type vhost
amqp:///shovel001 amqp091 queue001 2021-02-28 03:08:04 shovel001 amqp://rabbitmq.example.com:5672/%2F
exchange001 key001 amqp091 running dynamic vhost001
amqp:///shovel002 amqp091 queue002 2021-02-28 03:08:04 shovel002 amqp://rabbitmq.example.com:5672/%2F
exchange001 key004 amqp091 running dynamic vhost001
amqp:///shovel003 amqp091 queue001 2021-02-28 03:08:04 shovel003 amqp://rabbitmq.example.com:5672/%2F
exchange002 key001 amqp091 running dynamic vhost002
If there is a shovel that is in a "terminated" state, something like this should be returned.
2021-06-03 23:11:25 shovel002 terminated "needed a restart" dynamic /
The rabbitmqctl shovel_status command may return a shovel that has been deleted using the rabbitmqctl delete_shovel or rabbitmqctl clear_parameter commands. In this scenario, restarting the RabbitMQ service should make it so that the rabbitmqctl shovel_status command does not return the shovel in the list of shovels.
The --formatter json option can be used to return the output in JSON and then this can be piped through the python command to return JSON formatted output.
rabbitmqctl shovel_status --formatter json | python -m json.tool
[
{
"destination": "amqp:///foo",
"destination_protocol": "amqp091",
"destination_queue": "a.queue",
"last_changed": "2022-02-03 08:58:51",
"name": "a.shovel",
"source": "amqp:///bar",
"source_exchange": "a.exchange",
"source_exchange_key": "#.#.#.#",
"source_protocol": "amqp091",
"state": "running",
"termination_reason": "",
"type": "dynamic",
"vhost": "foo"
}
]
Did you find this article helpful?
If so, consider buying me a coffee over at