Engineering Decisions · Senior · Question 4 of 14

After saving an order, the service must publish an event to a broker. Events must not be lost, and the broker can't join a database transaction. What do you do?

Show the answer

Correct answer: A transactional outbox, published by a relay

Explanation

Writing the event in the same transaction as the order means both exist or neither does, and a relay delivers it later. Publishing after commit fits events you can afford to lose, but a crash between the two steps drops the event. Publishing first fits nothing that must stay consistent, because a failed commit leaves consumers reacting to an order that doesn't exist.

Further reading

Problem with a question

Engineering Decisions · Senior · question 4

Test yourself

Take the Engineering Decisions · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz