0Pricing
RabbitMQ Messaging & Async Systems · 课时

用于联邦的铲运插件

利用铲运插件在消息代理之间可靠地移动消息,即使跨越广域网也能实现。无缝集成不同的 RabbitMQ 实例或集群。

用于联邦的铲运插件 是 CoddyKit 上的免费 RabbitMQ Messaging & Async Systems 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 RabbitMQ Messaging & Async Systems 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 RabbitMQ Messaging & Async Systems 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Meet the RabbitMQ Shovel

Welcome to the Shovel plugin! RabbitMQ is great for local messaging, but what if you need to send messages between brokers located far apart, perhaps in different data centers?

The Shovel plugin is designed to reliably move messages from a queue on one RabbitMQ broker to an exchange or queue on another, even across wide area networks (WANs).

Why Use the Shovel Plugin?

The Shovel plugin acts like a bridge, offering several key benefits:

  • Broker Decoupling: Connect different RabbitMQ instances without complex network setups or full clustering.
  • WAN Reliability: It automatically handles network interruptions and reconnects, ensuring messages eventually reach their destination.
  • Data Replication: Useful for disaster recovery scenarios, replicating messages between primary and secondary brokers.
  • Version Compatibility: Bridge brokers running different RabbitMQ versions.

How Shovel Works: The Basics

Think of Shovel as a persistent helper:

  • It consumes messages from a specific source queue on one broker.
  • It then publishes these messages to a destination exchange or queue on another broker.
  • This process happens continuously and reliably, even if connections temporarily fail.

It's like having a dedicated worker whose only job is to move messages from point A to point B, no matter the distance.

Static vs. Dynamic Shovels

RabbitMQ offers two main types of shovels:

  • Static Shovels: These are configured directly on a RabbitMQ node, often via the command-line interface (CLI) or Management UI. They are fixed and run as long as the broker is active.
  • Dynamic Shovels: More flexible, these are configured using runtime parameters or policies. They can be created, updated, or deleted on the fly, making them ideal for more transient or policy-driven message flows.

Configuring a Static Shovel

To set up a static shovel, you define its source and destination. Here’s a conceptual CLI command:

rabbitmqctl shovel add [name] --uri=[source_uri] --source-queue=[q_name] --destination-uri=[dest_uri] --destination-exchange=[ex_name]

You specify connection details (URIs) for both brokers and the exact queue/exchange to use.

rabbitmqctl shovel add my-shovel \
  --uri=amqp://guest:guest@broker1:5672/ \
  --source-queue=my-local-queue \
  --destination-uri=amqp://guest:guest@broker2:5672/ \
  --destination-exchange=my-remote-exchange

Static Shovel Parameters

Let's break down the key parameters for a static shovel:

  • --uri: Connection string for the source broker.
  • --source-queue: The name of the queue on the source broker from which messages will be consumed.
  • --destination-uri: Connection string for the destination broker.
  • --destination-exchange (or --destination-queue): The name of the exchange or queue on the destination broker where messages will be published.

The plugin handles all the underlying AMQP connection management.

Dynamic Shovels via Policies

Dynamic shovels are powerful for managing many similar message flows. Instead of adding each shovel manually, you can define a policy.

A policy specifies rules (e.g., matching queue names with a pattern) that automatically create shovels. This is great for:

  • Automatically bridging new queues that match a naming convention.
  • Managing shovel configurations centrally.

Monitoring Your Shovels

It's important to monitor your shovels to ensure messages are flowing correctly.

You can check their status using the RabbitMQ Management UI (under the 'Shovels' tab) or via the CLI:

rabbitmqctl shovel status

Shovel Checkpoint

Test your understanding of RabbitMQ Shovel's capabilities.

Shoveling Messages: A Recap

You've learned about the powerful RabbitMQ Shovel plugin!

  • It reliably moves messages between different RabbitMQ brokers.
  • Shovel acts as a consumer on a source and a producer to a destination, handling reconnections automatically.
  • We covered both static (fixed configuration) and dynamic (policy-driven) shovels.
  • Shovel is crucial for integrating systems across WANs, ensuring message durability, and enabling disaster recovery.

It's an essential tool for building robust, distributed messaging systems!

常见问题解答

「用于联邦的铲运插件」课时是免费的吗?

是的 — 「用于联邦的铲运插件」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 RabbitMQ Messaging & Async Systems 课程的其余内容,请升级到 CoddyKit PRO。 RabbitMQ Messaging & Async Systems 课程共包含 4 节课。

「用于联邦的铲运插件」这节课中我会学到什么?

利用铲运插件在消息代理之间可靠地移动消息,即使跨越广域网也能实现。无缝集成不同的 RabbitMQ 实例或集群。 你通过在浏览器中直接运行的动手代码来练习 RabbitMQ Messaging & Async Systems,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 RabbitMQ Messaging & Async Systems 需要有经验吗?

无需任何先前经验。CoddyKit 上的 RabbitMQ Messaging & Async Systems 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。

「用于联邦的铲运插件」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 RabbitMQ Messaging & Async Systems 课中编写并运行代码吗?

能。每节 RabbitMQ Messaging & Async Systems 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 延迟消息插件
  2. 用于联邦的铲运插件
  3. 用于集群的联邦插件
  4. 消息去重与一致性哈希交换器插件
← 返回 RabbitMQ Messaging & Async Systems