أساسيات المراسلة (Messaging)
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- الطوابير (Queues)
- المواضيع (Topics)
- المنتجون (Producers)
- المستهلكون (Consumers)
- دلالات التسليم
تعلّم أولًا
2 ساعة تدريب (تقدير)
مخرجات التعلم
- Distinguish queues (point-to-point) from topics (publish/subscribe).
- Distinguish commands from events and name events in the past tense.
- Explain at-most-once, at-least-once, and effectively-once delivery, and why exactly-once delivery is not available end to end.
- Design an event payload (identity, timestamp, version, minimal vs full state).
الدروس
المختبر والتمارين
Lab
MID-026-LAB1 · Event catalog
Outcomes: 1–4 · Time: ~2 h
- List Shop's business events:
OrderPlaced,StockReserved,StockReservationFailed,PaymentAuthorized,PaymentFailed,OrderCancelled, and others you find. - For each give: owner service, past-tense name, schema (fields and types), version, key, consumers.
- Mark which messages are commands, and keep them out of the event list.
- Have a peer review the catalog.
Acceptance: reviewed catalog used by later labs.
Exercises (assessment: quiz plus catalog review; five exercises)
| ID | Outcome | Task |
|---|---|---|
| MID-026-EX01 | 1 | For notification emails, work distribution to image resizers, and order events, choose queue or topic and justify. |
| MID-026-EX02 | 2 | Classify and rename if needed: SendEmail, OrderShippedEvent, UpdateInventoryNow, PriceChanged. |
| MID-026-EX03 | 3 | Explain why exactly-once delivery is not available end to end, using a lost-ack timeline. |
| MID-026-EX04 | 3 | Write idempotent handling for PaymentAuthorized using the eventId. |
| MID-026-EX05 | 4 | Design OrderPlaced payloads in minimal and full-state versions and compare them. |
أظهر الحلول
- EX01 Emails and resizers: queue (competing consumers). Order events: topic (several independent subscribers).
- EX02
SendEmailcommand;OrderShippedEventevent (name asOrderShipped);UpdateInventoryNowcommand;PriceChangedevent. - EX03 Consumer processes and acks, but the ack is lost; the broker redelivers. The broker cannot know whether processing happened.
- EX04 Store processed
eventIds in a table with a unique constraint, in the same transaction as the effect; on duplicate key skip. - EX05 Minimal:
{eventId, orderId}, consumers callordersback (coupling, load). Full: includes lines and totals (autonomous consumers, bigger, schema must be versioned).
الاختبار
Outcomes: O1 queues and topics · O2 commands and events · O3 delivery semantics · O4 event payloads.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Five exercises MID-026-EX01 to EX05 plus the lab. Pass: at least four exercises correct and a peer-reviewed event catalog with owners, past-tense names, schemas, and versions.
أخطاء شائعة
Events that are commands in disguise; events carrying entire database rows.
التقييم
Quiz plus catalog review.
الصلة بالمسار الوظيفي
Event-driven architecture (SRB-002).