Event-Driven Architecture Made Simple: Dapr Meets Axon
In a compelling session at Dapr Day 2024, Marc Klefter walks us through an elegant solution for implementing CQRS and event sourcing in Dapr applications. For anyone wrestling with distributed systems, this integration might just be the missing piece you've been looking for.
Starting Simple: Command Routing [12:35]
Let's begin with the basics. Ever tried implementing command routing in a distributed system? Marc shows us how the Axon integration makes this surprisingly straightforward:
"Axon server is very basic when it comes to routing - intentionally so," Marc explains. "It's a stereotypical routing based on the command type, the name of it, or the kind and some identifier."
This simplicity is exactly what we need when building distributed systems. No unnecessary complexity, just clean, predictable routing.
The Real World Isn't Simple (And That's OK) [13:56]
But here's where it gets real. Command handling in production systems isn't just about getting a message from point A to point B. As Marc points out, we need to:
- Read relevant past events
- Process the current command
- Append new events
- Distribute events to interested handlers
It's like choreographing a dance where every step needs to be precise and coordinated.
Location Transparency: The Secret Sauce [17:22]
Here's where things get interesting. Marc introduces a concept that could change how you think about distributed systems:
"With messages, you don't really know where they end up - that's sort of the whole point," he says. This location transparency means your code doesn't need to know or care whether it's talking to a local service or one halfway around the world.
The Monolith-to-Microservices Journey [18:03]
Ready for the best part? Marc advocates for a practical approach that many of us secretly wish more teams would follow:
"You can start building a modular monolith...and then as you see fit, when the need arises, you can extract and scale parts of your system independently."
No more premature microservices! Start simple, evolve as needed, and let your architecture grow with your needs.
Smart Message Routing [19:27]
The message bus abstraction Marc presents is particularly clever. It can:
- Handle local routing when possible
- Seamlessly switch to remote routing when needed
- Maintain consistent APIs throughout
- Scale without application changes
What's Next? [21:24]
While the component is still evolving, it's already showing promise. Coming soon:
- Language-specific developer abstractions
- Full infrastructure component support
- Flexible deployment options
The Hidden Power of Pluggable Components [23:19]
The conversation takes an interesting turn at the end, revealing one of Dapr's lesser-known superpowers: pluggable components. This extensibility means the community can build and share custom integrations, potentially creating a rich ecosystem of solutions.
What This Means for You
Whether you're building a new system or maintaining an existing one, this Dapr-Axon integration offers some compelling benefits:
- Start simple with a modular monolith
- Scale naturally as needed
- Maintain clean separation of concerns
- Keep your options open for future evolution
The best part? You can start small and grow into it. No need to build everything at once.
Get Involved
The community is exploring the idea of creating a registry for custom Dapr components. Imagine having a central place to discover and share integrations like this one. Exciting times ahead!
Working on distributed systems? The Axon integration might be worth a look. Check out the Dapr documentation for more details, or reach out to Mark directly with questions.
Want to try it out or contribute? The community would love to hear about your experiences. Join the discussion on Discord!