Did you have a chance to work with the Outbox pattern?

If you're working with microservices, this is definitely something to add to your toolkit.

So what is it?

The Outbox pattern is a technique for reliably publishing events in a distributed system.
Instead of publishing events directly, the Outbox pattern involves storing events in a separate table in your database and then having a background process read from that table and publish the events to a message broker.
Why would you ever want to introduce this sort of complexity?

Well, if you're working with distributed systems you surely know that things break. A downstream service is down. The network isn't available.
If you couple your application requests with the process of notifying other services, either by directly calling them or publishing a message to the queue, you are introducing a potential issue.
The Outbox pattern is used to solve the problem of ensuring that events are published in a reliable way and you don't need to resort to complicated two-phase commits.

In a distributed system, it's common to have multiple services that need to be updated when an event occurs.
For example, if a user updates their profile, you might need to update multiple services with that new data.

By using the Outbox pattern, you can ensure that those updates happen reliably, even if some of the services are temporarily unavailable.
If you're working with a SQL database, for example, you know that your transaction is atomic.

You can reliably persist your message to the Outbox table and have a background worker process that message at a later time.
One of the key benefits of the Outbox pattern is that it helps you to ensure consistency in your distributed system.

By using a separate table to store events, you can be sure that events are only published at least once, and that they are published in the correct order.
Another benefit is that the Outbox pattern is generally easy to implement and can be used with any message broker or queueing system.
Plus, it can help you to improve the performance and scalability of your system by decoupling the act of publishing events from the rest of your application logic.
You can also add retries for failed messages, and try to publish them again later.

Of course, the Outbox pattern only takes care of the publishing side of things. On the consumer, you still need to think about duplicate messages in case of retries.
If you enjoyed this Tweet thread, you will love my weekly .NET newsletter. I share one actionable tip every Saturday, and it's less than a 5-minute read.

Join 9900+ engineers: milanjovanovic.tech
Lastly, I would appreciate it if you RT this to your audience so it can reach more people.

Have an awesome Tuesday. :)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Milan Jovanović

Milan Jovanović Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mjovanovictech

Feb 19
I worked on a system that has 10 API instances running in parallel and handles millions of requests per day.

And I wondered for the longest time what makes an API horizontally scalable.

I want to share my thoughts on this since I had a chance to work on a system like that.
Horizontal scalability is crucial for building distributed systems that can handle high loads and traffic.
Here are a few characteristics of a horizontally scalable API:
• Stateless
• Distributed architecture
• Load balanced
• Fault-tolerant
• Distributed caching

All right, that all sounds nice. But what does it mean?
Read 12 tweets
Feb 18
If you're building a distributed system, you will probably encounter the concept of Integration events.

Integration events are a pattern used to communicate between different components in a distributed system. Image
They can be used to notify other components of an action that has occurred or to request that another component perform a specific action.

One of the main benefits of using integration events is that they help to decouple different components of a system.
This means that each component can be developed and tested independently, without having to worry about how it will interact with other components.
Read 10 tweets
Feb 17
What is Structured logging?

You may have heard about it from a colleague, or even tried to add it to your .NET application.

And if you already know what it is, kudos to you.

But if you don't know, here's how I can help. Image
In tomorrow's newsletter, I'll discuss implementing structured logging with Serilog.

I'll show you how to:
• Install Serilog
• Configure Serilog using appsetings.json
• Work with structured logging syntax
And all that in less than a 5-minute read!

Join 9400+ engineers who will read about structured logging with Serilog tomorrow:
milanjovanovic.tech
Read 4 tweets
Jan 10
Why are you not working with Azure Functions? ⚡

I had the opportunity to work with Azure Functions on several projects, and I have consistently been impressed with their capabilities.

For those who may not be familiar, don't worry. Let me give you a brief intro. 🧵
Azure Functions are a serverless compute service that enables you to run code on-demand without having to provision or manage infrastructure.

You can focus on writing and testing your code without worrying about the underlying infrastructure.
Here are a few reasons why I believe Azure Functions are a valuable addition to any developer's toolkit:
- Cost-effective
- Scalability
- Integration
- Productivity
Read 15 tweets
Jan 9
Azure Functions are a serverless compute service that enables you to run code on-demand without having to provision or manage infrastructure.

You can focus on writing and testing your code without worrying about the underlying infrastructure.
Here are a few reasons why I believe Azure Functions are a valuable addition to any developer's toolkit:
- Cost-effective
- Scalability
- Integration
- Productivity
𝗖𝗼𝘀𝘁-𝗲𝗳𝗳𝗲𝗰𝘁𝗶𝘃𝗲

Because you only pay for the resources you consume, Azure Functions can help you save money compared to hosting your code on traditional infrastructure.
Read 7 tweets
Dec 27, 2022
Unit Tests vs Integration Tests

I've learned that both unit and integration tests are important for ensuring the quality and stability of my code.

However, the appropriate balance between the two types of tests will depend on the specific needs of your project.
Unit tests are designed to test individual units of code in isolation.

They are typically fast to run and easy to write, and they are great for verifying that a specific function or method is working as expected.
It's important to have a good suite of unit tests in place to ensure that your code is correct and maintainable.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(