Delivery guarantees, outbox and inbox patterns

Your code saves an order to the database and then publishes an “order placed” message. If the process crashes between those two steps, the order exists but nobody hears about it. Retry, and someone may hear about it twice. You’ll understand what at-most-once, at-least-once and exactly-once delivery really promise, and how the outbox pattern closes that gap by saving the message in the same transaction as the data.

The first article explains the guarantees and the outbox and inbox patterns. The next three are about building an outbox on PostgreSQL: a subtle ordering problem with sequences, and how to send messages as soon as they’re saved instead of polling for them. The last shows why you can’t have both strict ordering and high throughput, comparing PostgreSQL, MongoDB and Kafka.

Start with the first one; the PostgreSQL articles assume you know it.

  1. Outbox, Inbox patterns and delivery guarantees explained

    2020-12-30Yesterday I was asked by Cezary about the transactional outbox pattern sample implementation. My answer was: https://twitter.com/oskar_at_net/status/134418424710032998…
  2. How Postgres sequences issues can impact your messaging guarantees

    2022-10-28Big picture descriptions and overall explanations are great. They help us to understand the foundations of new ideas and then find the place we need to evaluate more…
  3. Push-based Outbox Pattern with Postgres Logical Replication

    2022-10-13There are only a few patterns that I’m comfortable saying: “You should use it always if you want to build mature system”. One of them is the Outbox Pattern. Why? Because…
  4. How to get all messages through Postgres logical replication

    2022-11-20In an earlier article, I described Push-based Outbox Pattern with Postgres Logical Replication. The idea is to store the outgoing message (e.g. event) in the same…
  5. The Order of Things: Why You Can't Have Both Speed and Ordering in Distributed Systems

    2025-07-14Picture this scenario: An online retailer runs a flash sale with 500 units of a hot product. Within minutes, they’ve processed 742 orders. Their inventory shows -24…