التبادلات البديلة للرسائل غير القابلة للتوجيه
تعلّموا كيفية إرفاق تبادل بديل (AE) لالتقاط الرسائل التي كان سيُتخلّص منها لعدم تطابق أي ارتباط، ومنع فقدان الرسائل بصمت.
التبادلات البديلة للرسائل غير القابلة للتوجيه درس مجاني في RabbitMQ Messaging & Async Systems على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في RabbitMQ Messaging & Async Systems، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة RabbitMQ Messaging & Async Systems 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Unroutable Message Problem
When a message reaches an exchange but matches no binding, RabbitMQ silently discards it (unless the publisher set the mandatory flag).
This silent loss is dangerous in production.
What Is an Alternate Exchange?
An Alternate Exchange (AE) is a fallback exchange. If the primary exchange cannot route a message, it forwards the message to its configured alternate exchange instead of dropping it.
Declaring an Alternate Exchange
You set the AE via the alternate-exchange argument when declaring the primary exchange.
channel.exchange_declare(
exchange='orders',
exchange_type='direct',
arguments={'alternate-exchange': 'orders-ae'}
)Declare the AE Itself
The alternate exchange must also exist. A fanout AE is common because it broadcasts to whatever catch-all queue you bind.
channel.exchange_declare(
exchange='orders-ae',
exchange_type='fanout'
)Bind a Catch-All Queue
Create a queue to collect the unroutable messages and bind it to the AE.
channel.queue_declare(queue='unrouted')
channel.queue_bind(queue='unrouted', exchange='orders-ae')How Routing Decides
The flow is:
- Message published to
orders - No binding matches the routing key
- Message diverted to
orders-ae - Lands in the
unroutedqueue
AE vs Mandatory Flag
The mandatory flag returns the unroutable message to the publisher via a basic.return.
An AE keeps it server-side in a queue. AE is better for centralized auditing; mandatory is better for immediate publisher-side handling.
Chaining Alternate Exchanges
An AE can itself have an alternate exchange, creating a fallback chain. Keep chains short to avoid confusing topology.
AE vs Dead Letter Exchange
Do not confuse them:
- AE: triggered at publish time when no binding matches
- DLX: triggered after a message is in a queue and is rejected, expires, or overflows
Operational Tips
- Always monitor the catch-all queue length
- Alert when it grows, since it signals routing bugs
- Process or inspect captured messages regularly
Permissions Note
The user declaring an exchange with an alternate exchange needs read permission on the AE and write permission on the primary exchange, per RabbitMQ's authorization model.
Quick Check
Confirm your grasp of alternate exchanges.
Recap
An Alternate Exchange prevents silent message loss by capturing unroutable messages and forwarding them to a fallback exchange and catch-all queue.
Set it with the alternate-exchange argument, monitor the catch-all queue, and remember AE is publish-time while DLX is queue-time.
تعلم RabbitMQ Messaging & Async Systems مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 11
- الدروس
- 44
الأسئلة الشائعة
هل درس «التبادلات البديلة للرسائل غير القابلة للتوجيه» مجاني؟
نعم — نص درس «التبادلات البديلة للرسائل غير القابلة للتوجيه» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة RabbitMQ Messaging & Async Systems، انتقل إلى CoddyKit PRO. تتضمن دورة RabbitMQ Messaging & Async Systems 4 دروس في المجموع.
ماذا ستتعلم في «التبادلات البديلة للرسائل غير القابلة للتوجيه»؟
تعلّموا كيفية إرفاق تبادل بديل (AE) لالتقاط الرسائل التي كان سيُتخلّص منها لعدم تطابق أي ارتباط، ومنع فقدان الرسائل بصمت. تتمرن على 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التعمّق في تبادل Headers
- ارتباطات التبادل بالتبادل
- تبادلات الرسائل الميتة (DLX)
- التبادلات البديلة للرسائل غير القابلة للتوجيه