Event-Driven Architecture (EDA) is exciting until you deal with event versioning.
There is one way: Send meeting invites to all teams. After 101 meetings, post your maintenance banner, and everyone hits the release button at the same time. Or...
Or you can use an Adapter but with a twist. Yes, like in 90% of the problems in Software Development, there is a Pattern that will help you find a smart solution.
Thank you to our sponsors who keep this newsletter free:
Multiplayer auto-documents your system, from the high-level logical architecture down to the individual components, APIs, dependencies, and environments. Perfect for teams looking to streamline system design and documentation management without the manual overhead.
The Problem
At this point, you understand the domain better, and a structural change makes perfect sense.
The problem is that you have a schema, and consumers already know how to process it, so they depend on you to keep compatibility but really need to break it.
Let’s talk about an example with a producer and 3 consumers.
The solution
Instead of falling into the trap of coordinated deployments, you can leverage the Adapter Pattern with a strategic twist. Here’s how it works in 5 steps:
Create a New Topic: When you introduce a new schema, instead of forcing all consumers to immediately adapt, you create a new topic. This topic will be the home for events generated using the new schema.
Introduce an Adapter: Deploy an adapter that listens to the new topic. This adapter translates the events back to the old schema format and republishes them to the original topic. This way, your existing consumers continue receiving events in the format they expect without any immediate changes.
Update the Producer: Modify the producer to generate events using the new schema and publish these events to the newly created topic.
Gradually Migrate Consumers: Now that you have both the old and new formats coexisting, you can start migrating consumers at your own pace. As you update each consumer to handle the new schema, simply point it to the new topic.
Decommission the Adapter: Once all consumers have been successfully migrated to the new schema, you can safely retire the adapter and the old topic.
The Benefits: Less Stress, More Agility
Backward Compatibility: The adapter ensures that your existing consumers continue to function without requiring immediate updates, maintaining system stability during the transition.
No Coordinated Deployments: By decoupling the migration of the producer and consumers, you eliminate the need for synchronized deployments. Each team can work independently, reducing the risk of errors.
Focused Testing: As each consumer is migrated, testing can be more focused and controlled. You can validate each transition individually, making identifying and resolving issues easier.
Reduced Meetings: With less coordination required, you can say goodbye to countless meetings. The migration process becomes simpler, more predictable, and less stressful.
The goal is to find the simplest and most effective solutions to breaking compatibility.
The Adapter Pattern provides a pragmatic approach to handling event versioning in EDA.
Say no to more meetings and start releasing the smart way: incrementally!
System Design Classroom is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.
Articles I enjoyed this week
Airbnb's Migration from Monolith to Services by
20 Patterns to Master Dynamic Programming by
Understand The 4 Shapes of Software Developers to Better Navigate Your Career By
Design is about the abstractions by
Load Balancer vs Reverse Proxy vs Forward Proxy vs API Gateway by
Thank you for reading System Design Classroom. If you like this post, Share it with your friends!
Great approach Raul.
Reminds me a bit of a Strangler-Fig-like approach only with events involved for a gradual migration. One risk is that the adapter becomes a permanent component. For this, I'd suggest keeping a hard deadline at some point when it will be decommissioned.
Also, thanks for the mention brother!
That's a great article, Raul! And thank you for the mention!