The Transactional Outbox and Delivery Retries

Record an outgoing event with the data change it represents and handle duplication between sending and marking the event delivered.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Commit state and its notification together
  2. Sending and acknowledging can still be separated by failure

Commit state and its notification together

When an application records an approved document, it may also need to notify another service. Sending before commit can announce an approval that later rolls back. Sending only after commit without a durable pending record can lose notification if the process stops. Insert an outbox row containing event identity and required payload in the same database transaction as the approval.

Sending and acknowledging can still be separated by failure

A worker reads committed outbox rows and sends them. If it stops after sending but before marking the row, another worker can send it again. A consumer can apply the event idempotently under that stable identity. Idempotency keys explain the receiver side. Exactly-once effects examine when state and external outputs need further coordination.[1][2]

References

  1. CMU 15-445/645, Introduction to Database Systems: Lectures ↩
  2. PostgreSQL Global Development Group, PostgreSQL Documentation ↩