The document discusses event sourcing as an architectural pattern, emphasizing its ability to track state changes through a sequence of events rather than just storing the current state of applications. It highlights the advantages and challenges of implementing event sourcing and CQRS, including issues related to consistency, validation, and parallel updates. The author argues for the importance of aligning implementation with business domain needs and notes the necessity of careful consideration in managing application state and event storage.
Example Domain
User
Guid id
Stringemail
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent
Guid id
Date timestamp
String email
String password
EmailChangedEvent
Guid userId
Date timestamp
String email
53.
We process 2million+
registrations per day. A user
can change her email address.
However the emails address
must be unique
54.
?
How high isthe
probability that a
validation fails
Which data is required
for the validation
Where is the required
data stored
55.
$
What is thebusiness
impact of a failed
validation that is not
recognized due to
eventual consistency
and how high is the
probability of failure
Example Domain
User
Guid id
Stringemail
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent
Guid id
Date timestamp
String email
String password
EmailChangedEvent
Guid userId
Date timestamp
String email
61.
What happens when
Aliceand Bob share an
account and both update the
email address at the same
time
?
Do you
REALLY
need afull lock
Most
„classic architecture“
applications are already
running fine with
optimistic locks
68.
Introduce a versionfield
for the domain entity
User
Guid id
Long version
String email
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent
Guid id
Date timestamp
String email
String password
EmailChangedEvent
Guid userId
Date timestamp
String email
Long version