Skip to content
Ameen Abozaid
Planned lessonMID-029-L07

Demo: processing the same message twice, safely

  • Lesson 7 of 7
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

show duplicate delivery and make inventory immune. Prepares MID-029-LAB1.

Draft outline details

Step by step

  1. Publish one OrderPlaced event to inventory; stock drops by 2.
  2. Replay the same record (reset the offset or resend); stock drops by 2 again. Show the bug.
  3. Add an inbox table with the event id as primary key and insert it in the same transaction.
  4. Planned mistake: keep processed ids in a HashSet. Restart the service, replay, and the duplicate is applied. Fix: durable inbox row.
  5. Replay again: the unique violation is caught, stock is unchanged, and a log line says "duplicate skipped".

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.