0Pricing
RabbitMQ Messaging & Async Systems · درس

إزالة تكرار الرسائل وإضافات تبادل التجزئة المتسقة

استكشفوا إضافتين عمليتين لـ RabbitMQ: تبادل التجزئة المتسقة لتوزيع الحمل، واستراتيجيات إزالة التكرار التي تحافظ على المعالجة مرة واحدة تمامًا.

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

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Beyond Built-in Exchanges

RabbitMQ plugins extend the broker with new exchange types and behaviors. Two useful ones are the consistent hash exchange and message deduplication plugins.

The Load Distribution Problem

Fanout broadcasts to all queues; direct sends to matched queues. Neither evenly spreads a stream across a set of queues by a key.

The consistent hash exchange solves this.

Enabling the Plugin

Enable the plugin on the broker before use.

rabbitmq-plugins enable rabbitmq_consistent_hash_exchange

Declaring the Exchange

Declare an exchange of type x-consistent-hash.

channel.exchange_declare(
    exchange='shards',
    exchange_type='x-consistent-hash'
)

Binding With Weights

Bind queues with a numeric weight as the binding key. Higher weight means a larger share of the hash ring.

channel.queue_bind(queue='shard-1', exchange='shards', routing_key='10')
channel.queue_bind(queue='shard-2', exchange='shards', routing_key='10')

How Hashing Distributes

The exchange hashes each message's routing key and maps it onto the ring, sending it to one bound queue. The same key always lands on the same queue, giving sticky distribution.

Use Cases for Hashing

  • Sharding work by customer or entity id
  • Keeping per-key ordering across parallel workers
  • Even load spread without manual partitioning

The Duplicate Delivery Problem

RabbitMQ guarantees at-least-once delivery, so retries can cause duplicates. Deduplication ensures the same logical message is processed once.

Deduplication Plugin

The community deduplication plugin adds an exchange that drops messages carrying a recently seen deduplication header within a TTL window.

props = pika.BasicProperties(headers={'x-deduplication-header': 'order-42'})

Plugin vs Application Dedup

The plugin is convenient but bounded by its cache window. For strong guarantees, also store processed ids in your application database as a backstop.

Operational Notes

  • Plugins must be enabled on every node in a cluster
  • Verify version compatibility with your broker
  • Test failover behavior before relying on it

Quick Check

Test your plugin knowledge.

Recap

The consistent hash exchange distributes a message stream evenly and stickily across queues by hashing the routing key, while deduplication plugins drop repeated messages within a cache window.

Enable plugins on all cluster nodes and back deduplication with application-level checks for strong guarantees.

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

هل درس «إزالة تكرار الرسائل وإضافات تبادل التجزئة المتسقة» مجاني؟

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

ماذا ستتعلم في «إزالة تكرار الرسائل وإضافات تبادل التجزئة المتسقة»؟

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

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

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

كم من الوقت يستغرق درس «إزالة تكرار الرسائل وإضافات تبادل التجزئة المتسقة»؟

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

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

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

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

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