إعادة المحاولة والتراجع التدريجي وDLQs
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
retry transient failures sensibly and park permanent ones.
الموضوعات المخطط لها
- Transient failures (timeout, deadlock) deserve a retry; permanent ones (bad payload, rule violation) never succeed.
- Use exponential backoff with a maximum attempt count; blocking retries stall the partition, so use retry topics for long delays.
- After the limit, send the message to a dead-letter queue (DLQ) with the error and original headers.
- Alert on DLQ depth and provide a way to replay after the fix.
- Spring Kafka offers
DefaultErrorHandlerwith backoff and a dead-letter recoverer (verify version before recording).
تفاصيل المخطط المبدئي
عرض عملي
var handler = new DefaultErrorHandler(
new DeadLetterPublishingRecoverer(template),
new ExponentialBackOff(500, 2.0)); // add a max elapsed time or attemptsاختبر فهمك
Why should a malformed payload go straight to the DLQ?
أظهر الإجابة
Retrying cannot fix it and only delays the messages behind it.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.