---
title: Configuring Dynamic Shovels
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Configuring Dynamic Shovels
## Overview {#overview}
This guide focuses on dynamically configured shovels. It assumes
familiarity with the key concepts behind the [Shovel plugin](./shovel).
:::tip
[Dynamic shovels](./shovel-dynamic) is the modern shovel type. When in doubt,
prefer dynamic shovels.
To make sure that some shovels start after cluster formation, combine
dynamic shovels with [definition import on boot](./definitions#import-on-boot).
:::
Unlike with static shovels, dynamic shovels are configured using [runtime parameters](./parameters).
They can be started and stopped at any time, including programmatically. Dynamic shovels
can be used for both transient (one-off) and permanently running workloads.
Information about dynamic shovels is stored in RabbitMQ's schema database,
along with users, permissions, queues, etc. They therefore can be
exported together with other [schema definitions](./definitions) in combination
with the [pre-declared topology mode](#predeclared-topology).
## Configuration {#configuration}
Dynamic shovels can be defined using [`rabbitmqadmin`](./management-cli), [`rabbitmqctl`](./cli), through the
[management HTTP API](./management), or (with the `rabbitmq_shovel_management` plugin [enabled](./plugins)) through
the management UI's administrative section.
A shovel is declared with a definition body, which is a JSON object. Some keys are mandatory, others are optional.
They control connection parameters, protocol used, message transfer source and destination,
[data safety](./confirms) protocol features, and more.
Every shovel belongs to a virtual host. Note that a Shovel can consume from and publish
to not only a different virtual host but an entirely different cluster, so
virtual host selection primarily acts as a way of organising shovels and access to them,
much like with the rest of [permission in RabbitMQ](./access-control).
Every shovel is also named. The name is used to identify shovels when [inspecting their status](#status),
[deleting them](#deleting) or [restarting them](#restarting).
## Declaring a Dynamic Shovel {#declaring}
In this example we will set up a dynamic shovel that will move messages from the queue `"source-queue"` in the
local RabbitMQ cluster to the queue `"target-queue"` on a remote RabbitMQ node, using AMQP 0-9-1.
### Using CLI Tools
A shovel can be declared using CLI tools or the [HTTP API](./http-api-reference).
With [`rabbitmqctl`](./cli), a shovel is declared using the `set_parameter` command that declares a [runtime parameter] (./parameters).
[`rabbitmqadmin`](./management-cli) includes dedicated commands for declaring shovels under the
`shovels` group, namedly `shovels declare_amqp091` and `shovels declare_amqp10`.
Here are examples that declare a dynamic shovel using CLI tools:
| Key | Description |
| src-uri |
Source connection URI. Mandatory. See
the AMQP URI reference for
information on how RabbitMQ treats AMQP URIs in general.
The value of this parameter can either be a string, or a list of
strings. If more than one string is provided, the shovel will
randomly pick one URI from the list until
one of the endpoints succeeds.
|
| src-protocol |
Protocol to use when connecting to the source.
Either amqp091, amqp10 or local. If omitted it will default to amqp091.
See protocol specific properties below.
|
| src-queue |
Source queue that the shovel will consume from.
The queue from which to consume. Either this
or
src-exchange (but not both) must be set.
If the source queue does not exist on the target virtual host, and
src-queue-args
parameter was not provided, shovel will declare a classic durable queue with no optional arguments.
Shovels can use a pre-declared topology instead of declaring the source.
See the [Predeclared topology](#predeclared-topology) section below.
|
| src-queue-args |
Optional arguments for
src-queue declaration, eg. the queue type.
|
| src-consumer-name |
Optional consumer name. This value is used as the [consumer tag](./consumers#consumer-tags)
when `src-protocol` is set to `amqp091` or `local` and as the link name when `src-protocol`
is `amqp10`.
If not specified, a random value is used.
|
| dest-uri |
Same as src-uri above but for destination connection.
|
| dest-protocol |
Protocol to use when connecting to the destination.
Either amqp091 or amqp10.
If omitted it will default to amqp091.
See protocol specific properties below.
|
| dest-queue |
The queue to which messages should be published. Either this
or
dest-exchange (but not both) may be set. If
neither is set then messages are republished with their original
exchange and routing key.
If the destination queue does not exist in the destination virtual host,
and
dest-queue-args parameter was not provided,
shovel will declare a classic durable queue with no optional arguments.
Shovels can use a pre-declared topology instead of declaring the destination.
See the [Predeclared topology](#predeclared-topology) section below.
|
| dest-queue-args |
Optional arguments for
dest-queue declaration, eg. the queue type.
|
guest),
whose connectivity is restricted to `localhost`.
In production environments, the default user should use a generated username and password,
or deleted entirely in favor of a manually created user.
### Pre-declared Topology {#predeclared-topology}
Shovels can use a pre-declared topology instead of declaring its source and destination.
For example, this may be necessary when the topology is [imported from a definitions file at boot time](./definitions#import-on-boot).
Using a pre-declared topology avoids a chicken-and-egg problem between the import of definitions and
Shovel plugin startup: the plugin must be enabled for definitions to pass validation (of the runtime parameters part).
Here is how the plugin can be configured to wait until the source is available [using `rabbitmq.conf`](./configure):
```ini
# all shovels started on this node will use pre-declared topology
shovel.topology.predeclared = true
```
If only some shovels need to use a pre-declared topology, the same behavior can be configured
for specific shovels using the following shovel properties:
| Key | Description |
| src-predeclared |
When set to true, the plugin waits until src-queue is available
instead of declaring the topology itself using src-queue-args.
|
| dest-predeclared |
When set to true, the plugin waits until dest-queue is available
instead of declaring the topology itself using dest-queue-args.
|
| Key | Description |
| reconnect-delay | The duration (in seconds) to wait before reconnecting to the brokers after being disconnected at either end. Default is 1. |
| ack-mode |
Determines how the shovel should acknowledge consumed messages.
Valid values are
on-confirm, on-publish, and no-ack.
on-confirm is used by default.
If set to
on-confirm (the default), messages are
acknowledged to the source broker after they have been confirmed
by the destination. This handles network errors and broker
failures without losing messages, and is the slowest option.
If set to
on-publish, messages are acknowledged to
the source broker after they have been published at the
destination (but not yet confirmed). Messages may be lost in the event of network or broker failures.
If set to
no-ack, automatic message acknowledgements will be used.
This option will offer the highest throughput but is not safe (will lose messages in the event of network or broker failures).
|
| src-delete-after |
Determines when (if ever) the shovel should delete
itself. This can be useful if the shovel is being treated
as more of a move operation - i.e. being used to move
messages from one queue to another on an ad hoc basis.
The default is
never, meaning the
shovel should never delete itself.
If set to
queue-length then the shovel will
measure the length of the source queue when starting up,
and delete itself after it has transferred that many
messages.
If set to an integer, then the shovel will transfer that
number of messages before deleting itself. This option cannot
be used together with
ack-mode set to no-ack.
|
| src-delete-after-duration |
A time-to-live for the shovel, in seconds. When the time is up,
the shovel will delete itself. See
Time-Based Deletion.
Values below a configurable minimum (60 seconds by default) are
automatically increased to it.
|
| src-prefetch-count |
The maximum number of unacknowledged messages copied over a shovel at
any one time. Default is 1000.
|
| src-exchange |
The exchange from which to consume. Either this
or
src-queue (but not both) must be set.
The shovel will declare an exclusive queue and bind it to the
named exchange with
src-exchange-key before consuming
from the queue.
If the source exchange does not exist on the source broker, it
will be not declared; the shovel will fail to start.
|
| src-exchange-key |
Routing key when using src-exchange.
|
| src-consumer-args | Consumer arguments, such as `x-single-active-consumer` or `x-stream-offset`. |
| dest-exchange |
The exchange to which messages should be published. Either this
or
dest-queue (but not both) may be set.
If the destination exchange does not exist on the destination broker,
it will be not declared; the shovel will fail to start.
|
| dest-exchange-key |
Routing key when using dest-exchange. If this is not
set, the original message's routing key will be used.
|
| dest-publish-properties |
A map (JSON object) of properties to overwrite when shovelling messages. Setting
headers this way is not currently supported. Default is {}.
|
| dest-add-forward-headers |
Whether to add x-shovelled headers to the
shovelled messages indicating where they have been shovelled
from and to. Default is false.
|
| dest-add-timestamp-header |
Whether to add x-shovelled-timestamp headers to the
shovelled messages containing timestamp (in seconds since epoch)
when message had been shovelled. Default is false.
|
| Key | Description |
| src-uri |
The AMQP URI for the source. Mandatory. AMQP 1.0 URIs implement
as subset of what is described in the AMQP URI reference.
There is no virtual host concept in AMQP 1.0, so URI path
segments are not supported. The set of query parameters it supports are different from AMQP 0.9.1
URI(s):
|
| src-address | The AMQP 1.0 link address. Mandatory. |
| dest-address | The AMQP 1.0 link address. Mandatory. |
| src-prefetch-count |
The maximum number of unacknowledged messages copied over a shovel at
any one time. Default is 1000.
|
| dest-properties | Properties to overwrite when shovelling messages. See AMQP 1.0 spec §3.2.4 for details of all possible properties. |
| dest-application-properties | Application properties to set when shovelling messages. |
| dest-add-forward-headers |
Whether to add x-shovelled application properties to the
shovelled messages indicating where they have been shovelled
from and to. Default is false.
|
| dest-add-timestamp-header |
Whether to set the creation_time header to the
timestamp (in milliseconds since epoch) of the moment when
message had been republished. Default is false.
|
| reconnect-delay | The duration (in seconds) to wait before reconnecting to the brokers after being disconnected at either end. Default is 1. |
| ack-mode |
Determines how the shovel should acknowledge consumed messages.
Valid values are
on-confirm, on-publish, and no-ack.
on-confirm is used by default.
If set to
on-confirm (the default), messages are
acknowledged to the source broker after they have been confirmed
by the destination. This handles network errors and broker
failures without losing messages, and is the slowest option.
If set to
on-publish, messages are acknowledged to
the source broker after they have been published at the
destination (but not yet confirmed). Messages may be lost in the event of network or broker failures.
If set to
no-ack, automatic message acknowledgements will be used.
This option will offer the highest throughput but is not safe (will lose messages in the event of network or broker failures).
|
| src-delete-after |
Determines when (if ever) the shovel should delete
itself. This can be useful if the shovel is being treated
as more of a move operation - i.e. being used to move
messages from one queue to another on an ad hoc basis.
The default is
never, meaning the
shovel should never delete itself.
If set to an integer, then the shovel will transfer that
number of messages before deleting itself. This option cannot
be used in conjunction with
ack-mode: no-ack.
|
| src-delete-after-duration |
A time-to-live for the shovel, in seconds. When the interval elapses,
the shovel will delete itself. See
Time-Based Deletion.
Values below a configurable minimum (60 seconds by default) are
automatically increased to it.
|
| Key | Description |
| reconnect-delay | The duration (in seconds) to wait before reconnecting to the brokers after being disconnected at either end. Default is 1. |
| ack-mode |
Determines how the shovel should acknowledge consumed messages.
Valid values are
on-confirm, on-publish, and no-ack.
on-confirm is used by default.
If set to
on-confirm (the default), messages are
acknowledged to the source broker after they have been confirmed
by the destination. This handles network errors and broker
failures without losing messages, and is the slowest option.
If set to
on-publish, messages are acknowledged to
the source broker after they have been published at the
destination (but not yet confirmed). Messages may be lost in the event of network or broker failures.
If set to
no-ack, automatic message acknowledgements will be used.
This option will offer the highest throughput but is not safe (will lose messages in the event of network or broker failures).
|
| src-delete-after |
Determines when (if ever) the shovel should delete
itself. This can be useful if the shovel is being treated
as more of a move operation - i.e. being used to move
messages from one queue to another on an ad hoc basis.
The default is
never, meaning the
shovel should never delete itself.
If set to
queue-length then the shovel will
measure the length of the source queue when starting up,
and delete itself after it has transferred that many
messages.
If set to an integer, then the shovel will transfer that
number of messages before deleting itself. This option cannot
be used in conjunction with
ack-mode : no-ack.
|
| src-delete-after-duration |
A time-to-live for the shovel, in seconds. When the time is up,
the shovel will delete itself. See
Time-Based Deletion.
Values below a configurable minimum (60 seconds by default) are
automatically increased to it.
|
| src-prefetch-count |
The maximum number of unacknowledged messages copied over a shovel at
any one time. Default is 1000.
|
| src-exchange |
The exchange from which to consume. Either this
or
src-queue (but not both) must be set.
The shovel will declare an exclusive queue and bind it to the
named exchange with
src-exchange-key before consuming
from the queue.
If the source exchange does not exist on the source broker, it
will be not declared; the shovel will fail to start.
|
| src-exchange-key |
Routing key when using src-exchange.
|
| src-consumer-args | Consumer arguments, such as `x-single-active-consumer` or `x-stream-offset`. |
| dest-exchange |
The exchange to which messages should be published. Either this
or
dest-queue (but not both) may be set.
If the destination exchange does not exist on the destination broker,
it will be not declared; the shovel will fail to start.
|
| dest-exchange-key |
Routing key when using dest-exchange. If this is not
set, the original message's routing key will be used.
|
| dest-add-forward-headers |
Whether to add x-opt-shovelled headers to the
shovelled messages indicating where they have been shovelled
from and to. Default is false.
|
| dest-add-timestamp-header |
Whether to add x-opt-shovelled-timestamp headers to the
shovelled messages containing timestamp (in seconds since epoch)
when message had been shovelled. Default is false.
|