22 Event Sourcing

WHAT’S IN THIS CHAPTER?

  • An introduction to event sourcing and the problems it solves
  • Guidance and examples for building event-sourced domain models
  • How to build an Event Store
  • Examples of building Event Stores on top of RavenDB and SQL Server
  • Examples of using Greg Young’s Event Store
  • A discussion of how CQRS synergizes with event sourcing
  • A list of trade-offs to help you understand when event sourcing is a good choice and when you should avoid it

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/domaindrivendesign on the Download Code tab. The code is in the Chapter 22 download and individually named according to the names throughout the chapter.

Bringing a competitive business advantage and exciting technical challenges, it’s clear why a storage mechanism called event sourcing has gained a lot of popularity in recent years. Because a full history of activity is stored, event sourcing allows businesses to deeply understand many aspects of their data, including detailed behavior of their customers. With this historical information, new and novel queries can be asked that inform product development, marketing strategies, and other business decisions. Using event sourcing, you can determine what the state of the system looked like at any given point in time and how it reached any of those states. For many domains, this is a game-changing capability.

Many systems today store only the current state ...

Get Patterns, Principles, and Practices of Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.