Skip to content

Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


Follow @CodeOpinion

Event Sourcing

Testing your Domain when Event Sourcing

How do you test your domain when Event Sourcing? I find testing aggregates with Event Sourcing to be simpler than testing if you’re storing the current state. The inputs to your aggregate are events and the output of your aggregate are events. Given a stream of events When a valid command is performedThen new event(s) occurs YouTube Check out my YouTube channel where I post all kinds of content that accompanies my posts including this video showing everything that is in this post. Event Sourcing I’ve covered Event Sourcing in my Event Sourcing Example & Explained in plain English post. So check… Read More »Testing your Domain when Event Sourcing

Snapshots in Event Sourcing for Rehydrating Aggregates

Once you understand how Event Sourcing works, the most common thought is: “What happens when you have a lot of Events? Won’t it be inefficient to fetch every event from the event stream and replay all of them to get to the current state?”. It might be. But to combat this, you can use snapshots in event sourcing to rehydrate aggregates. Snapshots give you a representation of your aggregates state at a point in time. You can then use this as a checkpoint and then only replay the events since the snapshot. YouTube Check out my YouTube channel where I post all… Read More »Snapshots in Event Sourcing for Rehydrating Aggregates

Projections in Event Sourcing: Build ANY model you want!

Projections in Event Sourcing are a way to derive the current state from an event stream. This can be done asynchronously as events are persisted to an event stream which can update a projection. You don’t need to replay all the events in an event stream to get to the current state for a UI every time you need to display data. This could be very inefficient if you have a lot of events in a stream. Rather, create a projection that represents the current state and keep it updated as events occur. YouTube Check out my YouTube channel where I post… Read More »Projections in Event Sourcing: Build ANY model you want!