RabbitMQ Messaging & Async Systems · درس

إضافة Shovel للاتحاد

استخدم إضافة Shovel لنقل الرسائل بشكل موثوق بين الوسطاء، حتى عبر شبكات WAN. ادمج مثيلات RabbitMQ أو عناقيدها المختلفة بسلاسة.

الدرس 2 من 410 خطوة

إضافة Shovel للاتحاد درس مجاني في RabbitMQ Messaging & Async Systems على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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!

البدء مجانًا

تعلم RabbitMQ Messaging & Async Systems مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
11
الدروس
44

الأسئلة الشائعة

هل درس «إضافة Shovel للاتحاد» مجاني؟

نعم — نص درس «إضافة Shovel للاتحاد» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة RabbitMQ Messaging & Async Systems، انتقل إلى CoddyKit PRO. تتضمن دورة RabbitMQ Messaging & Async Systems 4 دروس في المجموع.

ماذا ستتعلم في «إضافة Shovel للاتحاد»؟

استخدم إضافة Shovel لنقل الرسائل بشكل موثوق بين الوسطاء، حتى عبر شبكات WAN. ادمج مثيلات RabbitMQ أو عناقيدها المختلفة بسلاسة. تتمرن على RabbitMQ Messaging & Async Systems مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ RabbitMQ Messaging & Async Systems؟

لا تُشترط خبرة سابقة. RabbitMQ Messaging & Async Systems على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «إضافة Shovel للاتحاد»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس RabbitMQ Messaging & Async Systems هذا؟

نعم. كل درس في RabbitMQ Messaging & Async Systems يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. إضافة الرسائل المؤجلة
  2. إضافة Shovel للاتحاد
  3. إضافة Federation للتجميع
  4. إزالة تكرار الرسائل وإضافات تبادل التجزئة المتسقة
← العودة إلى RabbitMQ Messaging & Async Systems