Member-only story
Why you should use the Outbox pattern in your code
Bending the Clean Architecture Principle
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:
In a nutshell, the client creates an account by calling an API Endpoint
from the website. Then, we would create a new account…