Shovel

What is a shovel?

A shovel is a mechanism in RabbitMQ used to transfer messages from one broker to another, such as between different servers. It can be configured to move messages between the following:

  • One exchange to another exchange
  • One exchange to a queue
  • One queue to an exchange
  • One queue to another queue

How does a shovel work?

A shovel connects to the source and destination, authenticates, then consumes and republishes messages. If a failure occurs, it automatically retries.

A shovel can be created and managed through the LavinMQ HTTP API or the LavinMQ management console.

API

To create a shovel using the LavinMQ API, send a POST request to the /api/parameters/shovel/ endpoint with the required configuration.

Example: API - create a shovel

POST http://<rabbitmq-server>/api/parameters/shovel/<vhost>/<shovel-name>

Example: Payload

{
  "component": "shovel",
  "name": "my_shovel",
  "value": {
    "src-uri": "amqp://source-server",
    "src-type": "queue", // Source type (queue or exchange)
    "src-queue": "source-queue", // Source queue name (use src-exchange for exchanges)
    "dest-uri": "amqp://destination-server",
    "dest-type": "queue", // Destination type (queue or exchange)
    "dest-queue": "destination-queue",
    "ack-mode": "on-confirm"
  }
}

In this example:

  • The shovel moves messages from the source-queue on the source server to the destination-queue on the destination server.
  • src-type and dest-type define the type of the source and destination: either queue or exchange.
    • If **src-type** is queue, use src-queue to specify the source queue.
    • If **src-type** is exchange, use src-exchange to specify the source exchange.
    • Similarly, for the dest-type, if it’s queue, use dest-queue; if it’s exchange, use dest-exchange.
  • The **ack-mode**is set toon-confirm, ensuring messages are acknowledged once they are confirmed by the destination.
  • The prefetch-count is set to 100, controlling how many messages can be prefetched at once before acknowledging them.
Virtual host Any vhost chosen
Name (shovel-name) The name of the shovel

Source

URI (src-uri) The URI for the source server (e.g., amqp://source-server).
Type (src-type) Select whether the source is a “queue” or an “exchange”.
Endpoint queue (src-queue) Source queue
Endpoint exchange (src-exchange) This can be used instead of src-queue if source type is "exchange”.
Prefetch (prefetch-count) How many messages to be prefetched.
Auto delete (auto-delete) When enabled, the shovel will transfer all messages from the queue and delete itself once done. If set to false, it will persist until explicitly removed.
Routing key (dest-routing-key) The routing key is only needed when shoveling messages to an exchange and controlling the routing.

Destination

URI (dest-uri) The URI for the destination server (e.g., amqp://destination-server).
Type (dest-type) Select whether the destination is a “queue” or an “exchange”.
Endpoint queue (dest-queue) Destination queue
Endpoint exchange (dest-exchange) This can be used instead of dest-queue if destination type is "exchange”.
Reconnect delay (reconnect-delay) Delay in seconds before attempting to reconnect in case of failure.
Ack mode (ack-mode) Set the acknowledgment mode (e.g., on-confirm or none).

Full API documentation can be found in the HTTP API for parameters for components and main.


Ready to take the next steps? Here are some things you should keep in mind:

Managed LavinMQ instance on CloudAMQP

LavinMQ has been built with performance and ease of use in mind - we've benchmarked a throughput of about 1,000,000 messages/sec. You can try LavinMQ without any installation hassle by creating a free instance on CloudAMQP. Signing up is a breeze.

Help and feedback

We welcome your feedback and are eager to address any questions you may have about this piece or using LavinMQ. Join our Slack channel to connect with us directly. You can also find LavinMQ on GitHub.