الإقرارات وprefetch
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
avoid message loss with manual acks.
الموضوعات المخطط لها
- Auto-ack removes the message on delivery; a crash during processing loses it.
- Manual ack: acknowledge after the work succeeds;
nackorrejectwith or without requeue on failure. - Unacknowledged messages return to the queue if the consumer dies.
- Prefetch (QoS) limits unacknowledged messages per consumer; it balances load and memory.
- Requeue loops forever on a poison message unless you route it to a dead-letter queue.
- Make handlers idempotent; redelivery is normal.
تفاصيل المخطط المبدئي
عرض عملي
@RabbitListener(queues = "email")
void handle(Message m, Channel ch, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
try { process(m); ch.basicAck(tag, false); }
catch (Exception e) { ch.basicNack(tag, false, false); } // no requeue: dead-letter
}Set acknowledge mode manual and prefetch in the listener configuration (verify property names for the Spring Boot version before recording).
اختبر فهمك
Why is auto-ack risky?
أظهر الإجابة
The message is removed before the work completes, so a crash loses it.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.