Member-only story

Why you should use the Outbox pattern in your code

Bending the Clean Architecture Principle

Anthony Trad
4 min readNov 28, 2022

Introduction

In a distributed system or a Microservices Architecture, you will somehow and eventually get into Messaging and Message Brokers. You want to save and reconstruct state in your application and make sure all communication is defined in a clean generic contract that you can safely scale, version and evolve.

While this is all good and thoughtful, you always need to deal with another resource such as a database or anything really. Synchronizing both and making sure operations are atomic is really a pain…

Here’s how this is a problem and how you can solve it!

The Problem

Let’s throw in a simple diagram of what we’re trying to achieve. Let’s say I am crafting a Stock Charting App. Simply, users do create an account and can visualize the stock market as they please. Now, I want to represent the Add User functionality in my system:

Add User Scenario 1

In a nutshell, the client creates an account by calling an API Endpointfrom the website. Then, we would create a new account…

--

--

Anthony Trad
Anthony Trad

Written by Anthony Trad

Senior Software Engineer focused on .NET and the Cloud. Reconsidering major principles and patterns, ideas are my own.

Responses (5)