---
title: "Discussion on \"Order Saved but the Email Never Went Out: The Outbox Pattern Explained\" | Hashnode"
description: "Discussion on \"Order Saved but the Email Never Went Out: The Outbox Pattern Explained\". A customer placed an order on a Saturday evening. The payment went through. The order was sitting in our database with status PAID.\nBut the confirmation email never arrived. The warehouse never got th"
url: "https://hashnode.com/posts/order-saved-email-never-sent-outbox-pattern/6b065c23e60a197e8bb9553a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Order Saved but the Email Never Went Out: The Outbox Pattern Explained](https://cloudtechbydevang.com/order-saved-email-never-sent-outbox-pattern?utm_source=hashnode&utm_medium=feed)

A customer placed an order on a Saturday evening. The payment went through. The order was sitting in our database with status PAID. But the confirmation email never arrived. The warehouse never got th

5d ago · 6 min read · cloudtechbydevang.com  
Read the article

-   [#devops](https://hashnode.com/tag/devops)
-   [#backend](https://hashnode.com/tag/backend)
-   [#system-design](https://hashnode.com/tag/system-design)
-   [#microservices](https://hashnode.com/tag/microservices)

## Written by

[Devang Pandya](https://hashnode.com/@cloudtechbydevang)

@cloudtechbydevang · Pune, India

  
[View profile](https://hashnode.com/@cloudtechbydevang)

Cloud | DevOps | AI made simple · 14+ yrs on AWS, GCP & Kubernetes

I help engineers learn cloud, DevOps, SRE and AI in simple English, crack interviews and follow clear roadmaps. 14+ years building and running platforms on AWS, GCP, Kubernetes and Terraform. One topic a day.

## Responses 1

Markdown supported · ⌘↵ to post

[Two Wang](https://hashnode.com/@twowang59)

[5d ago](https://hashnode.com/posts/order-saved-email-never-sent-outbox-pattern/6b065c23e60a197e8bb9553a/comment/6b0667fa178187462ae57d7d)

Solid write-up - the dual-write framing and the SKIP LOCKED relay are exactly right. Two things I would add for anyone taking this to production:

1.  Per-aggregate ordering is not automatic just because you set the Kafka partition key. With several relay workers and FOR UPDATE SKIP LOCKED, worker A can grab event #1 for an order while worker B grabs event #2 for the same order and publishes it first. Either serialize per aggregate in the relay (advisory lock on aggregate\_id) or attach a per-aggregate sequence number and have consumers reject stale ones.
    
2.  The outbox only fixes the producer side. If the broker loses the message after the relay marks the row as sent (non-durable topic, or a consumer that acks and then dies), the event is gone again. End-to-end still needs a durable log plus consumer-side dedupe on the outbox row id - the same unique-constraint table you describe - and a replay path that can republish from the outbox.
    

Good call on the outbox-lag metric; it is the one signal that separates "quietly broken" from "working". A pg\_notify in the same transaction also cuts relay latency for free until you move to Debezium.
