المستهلك النشط الوحيد
تعلّموا كيف تضمن ميزة المستهلك النشط الوحيد المعالجة بالترتيب عبر توجيه جميع الرسائل إلى مستهلك واحد في كل مرة، مع التحويل التلقائي إلى المستهلكين الاحتياطيين.
المستهلك النشط الوحيد درس مجاني في RabbitMQ Messaging & Async Systems على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في RabbitMQ Messaging & Async Systems، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة RabbitMQ Messaging & Async Systems 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Ordering vs Parallelism
Competing consumers boost throughput but break strict ordering: messages spread across workers can finish out of order.
Some workflows need both a hot standby and guaranteed sequence.
What Is Single Active Consumer?
Single Active Consumer (SAC) ensures only one consumer receives messages from a queue at a time, even if many consumers subscribe.
Others wait in line as standbys.
Enabling SAC
Set the x-single-active-consumer argument to true when declaring the queue.
channel.queue_declare(
queue='ordered-tasks',
durable=True,
arguments={'x-single-active-consumer': True}
)Automatic Failover
If the active consumer disconnects or its channel closes, RabbitMQ promotes the next registered consumer to active automatically.
This gives high availability without losing ordering.
Registration Order
Consumers become active in the order they registered. The first to subscribe becomes active; the rest queue up as standbys.
SAC vs Exclusive Consumer
- Exclusive: only one consumer is even allowed; others get an error
- SAC: many can subscribe, but only one is active; others stand by for failover
Subscribing as a Standby
Standby consumers subscribe normally. They simply receive no messages until promoted.
channel.basic_consume(queue='ordered-tasks', on_message_callback=handle)Guaranteed Order
Because only one consumer processes at a time, messages are handled in FIFO order as long as the consumer acks sequentially and prefetch keeps the pipeline tidy.
Throughput Trade-off
SAC sacrifices parallelism: throughput is bound to a single consumer. Use it only when ordering matters more than raw speed.
Inspecting the Active Consumer
The management UI and CLI mark which consumer is active. This helps verify failover behaved as expected during incidents.
Good Use Cases
- Sequential state machines
- Per-entity event streams that must stay ordered
- Workflows needing a warm standby worker
Quick Check
Check your understanding of SAC.
Recap
Single Active Consumer routes all messages to one consumer at a time, preserving FIFO ordering while keeping standbys ready for instant failover.
Enable it with x-single-active-consumer, and accept the throughput trade-off when order matters most.
الأسئلة الشائعة
هل درس «المستهلك النشط الوحيد» مجاني؟
نعم — نص درس «المستهلك النشط الوحيد» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة RabbitMQ Messaging & Async Systems، انتقل إلى CoddyKit PRO. تتضمن دورة RabbitMQ Messaging & Async Systems 4 دروس في المجموع.
ماذا ستتعلم في «المستهلك النشط الوحيد»؟
تعلّموا كيف تضمن ميزة المستهلك النشط الوحيد المعالجة بالترتيب عبر توجيه جميع الرسائل إلى مستهلك واحد في كل مرة، مع التحويل التلقائي إلى المستهلكين الاحتياطيين. تتمرن على 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- نمط المستهلكين المتنافسين
- عدد الجلب المسبق (جودة الخدمة)
- المستهلكون الحصريون وأولوية المستهلكين
- المستهلك النشط الوحيد