Demo: processing the same message twice, safely
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
- 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".
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.