Saving Data and a Notification Intent Together
A database transaction can persist a state change and an event record describing work another process should deliver later.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace publication
Publishing an article and adding a pending notification record in one transaction avoids needing two separate successful commits. The transactional outbox explains this approach.
Check delivery separately
A sender may deliver twice if acknowledgement of delivery is lost. The consumer still needs an appropriate repeat policy. See handling repeated events.[1]
Commit the fact and its delivery intent together
Suppose a booking becomes confirmed and an email should follow. Saving a notification intent in the same transaction as confirmation prevents a committed booking without its recorded pending work. A separate worker can deliver outstanding intents. See transaction boundaries.
Transaction: update booking, insert pending notification
Rollback: neither record persists
Commit: both persist
Sender reads committed pending intent later
Design for retry after sending
A worker may send successfully and fail before recording completion. Delivery deduplication or idempotent downstream behavior may be needed. Test that failure timeline along with ordinary rollback.