عرض عملي: معالجة الرسالة نفسها مرتين بأمان
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
show duplicate delivery and make inventory immune. Prepares MID-029-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Publish one
OrderPlacedevent toinventory; stock drops by 2. - Replay the same record (reset the offset or resend); stock drops by 2 again. Show the bug.
- Add an
inboxtable with the event id as primary key and insert it in the same transaction. - Planned mistake: keep processed ids in a
HashSet. Restart the service, replay, and the duplicate is applied. Fix: durable inbox row. - Replay again: the unique violation is caught, stock is unchanged, and a log line says "duplicate skipped".
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.