Fintech Lab
Lesson 35Distributed transactionsAdvanced
The outbox pattern
Reliably fan out side-effects after a ledger entry commits.

Every journal entry usually triggers side-effects: SMS the user, email the merchant, fire a webhook to a partner, push a notification to your mobile app. Naive code does the SMS send right after the INSERT in the same function. This has three failure modes, the SMS goes out before the DB commits, the DB commits but the SMS fails, or the process crashes in between. The outbox pattern fixes all three by putting the side-effect intent INSIDE the same database transaction as the ledger entry. A separate worker reads pending outbox rows and sends. At-least-once delivery guaranteed. The journal entries below are simple deposits; the lesson is in the commentary about HOW to commit them safely alongside their side-effects.

Fintech Lab is a free, interactive lab for fintech engineers. Real ledger, your own sandbox, engineering patterns from production. See all 85 lessons.

Search lessons

Type to find any of the 85 lessons. Press Enter to open.