Time Keeps On Slipping
a brief introduction into Event Sourcing
Jeroen v.d. Gulik
• CTO / Co-Founder Isset (http://isset.nl)
• Señor Developer
• Builder of Artificial Stupidity
• @n0x13
“Those who cannot remember the past are condemned to repeat it”
- George Santayana
As a Content owner I want to know which Content has been
edited more than X times
As a Content owner I want to know which Content has been edited more than X times and by whom
As an Editor I want to see all the changes that have
been made
RDBMS: Store data as the current representation
What if …
• Multiple authors
• Retract all changes from 1 editor
• Move content to different author
• Move content to different creator / updater
Store all the Changes (Δ delta’s),that have
happened
Don't save the current state of objects
Save the changes that lead to the current State
Something that has happened in the past
Example
• ContentWasCreated
• ContentWasEdited
• ContentChangedAuthor
Advantages
• Complete log of every state change ever
• Complete trace/audit trail
• Debugging heaven
• Very good performance (append only)
• No more mapping objects to tables
Replay all the Events to get the Current State
What about performance?
Computers are fastMany thousands of events replayed per second
SnapshotStore your state at a certain point in time
CQRSCommand Query Responsibility Segregation
Disclaimer: One doesn’t imply the other
Best of both worlds
Why use Event Sourcing?
• Easy to go from Event Sourcing to RDBMS
• From RDBMS to Event Sourcing, you start from scratch
Learn more!• Implementing Domain-Driven Design by Vaughn
Vernon
• http://docs.geteventstore.com/introduction/event-sourcing-basics/
• http://www.martinfowler.com/eaaDev/EventSourcing.html
• http://verraes.net/2014/03/practical-event-sourcing/
• https://www.youtube.com/watch?v=JHGkaShoyNs