Pick the fix
An order service commits the order, then publishes OrderPlaced. Sometimes the publish fails and shipping never hears about it. Fix?
Hint 1 of 1
How can the order and the event commit together?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Insert OrderPlaced into an outbox table in the order's transaction; a relay publishes it
Correct. The event exists if and only if the order committed.
A database commit and a broker publish are two systems that can't commit together. Writing the event as a row in the same transaction makes it atomic with the order; a relay publishes it later, at least once.
Why not the others?
- B Publish first, then commit. Now a failed commit leaves an event for an order that doesn't exist.
- C Retry the publish three times. A crash between commit and publish still loses it.
- D Use a bigger broker cluster. Doesn't address the crash between two systems.