event sourcing the best ubiquitous pattern you have never heard off
TRANSCRIPT
![Page 1: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/1.jpg)
Event Sourcing :The Best Ubiquitous Pattern You've Never Heard Of
Joe Drumgoole
Director of Developer Advocacy, EMEA@jdrumgoole
V1.1
![Page 2: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/2.jpg)
2
Event Sourcing – not a new idea
![Page 3: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/3.jpg)
3
Our Relational Friends Love It
![Page 4: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/4.jpg)
4
We do It Ourselves
![Page 5: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/5.jpg)
5
Think of a File backup system
Source Disk
Backup Disk
![Page 6: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/6.jpg)
6
Trivial Backup
Source Disk
Backup DiskMyFile.jpg
![Page 7: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/7.jpg)
7
But…
Source Disk
Backup DiskMyFile.jpg
MyFile.jpg
![Page 8: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/8.jpg)
8
Lets Use a Backup Tool
Source Disk
Backup DiskMyFile.jpg
MyFile.jpg
Admin
![Page 9: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/9.jpg)
9
What if We are a SaaS Backup Company?
MyFile.jpg MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
AuditMyFile.jpg
MyFile.jpgMyFile.jpg
MyFile.jpgMyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpgMyFile.jpg
MyFile.jpgMyFile.jpg
MyFile.jpgMyFile.jpg
MyFile.jpg
Audit
![Page 10: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/10.jpg)
10
What real SaaS Backup Companies do
Event 1MyFile.jpg
Event 2
Event 3
Event 4
Event 5
Event N
MyFile.jpg Start
MyFile.jpg End
![Page 11: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/11.jpg)
11
Where else is this Useful?
![Page 12: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/12.jpg)
How Did I Get Here?
![Page 13: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/13.jpg)
What's in the Box?
![Page 14: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/14.jpg)
An Immutable Append Only Log
![Page 15: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/15.jpg)
Snapshots for point in time state
![Page 16: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/16.jpg)
16
Where Do Events Come From?
Commands
Root Aggregate
Business Events
Aggregate Value
AggregateValue
Event 1
Event 2
Event 3
Event 4
Event 5
Event 6
Event 7
Event 8
Event 9
Event N
Event N + 1
![Page 17: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/17.jpg)
Snapshots for point in time state
![Page 18: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/18.jpg)
18
Some Example Snapshot Queries
• What POs failed to get approved in Q2?• Which cabs billed more than $50 a journey?• Which cabs get the biggest tips?• How many baskets have had $200 for two weeks or more?• Which sensor events exceeded the safety threshold on 21-July-
2016?
![Page 19: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/19.jpg)
CQS
CQRS
Command Query Segregation
Command Query Responsibility Segregation
Begat
![Page 20: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/20.jpg)
20
Split the ResponsibilitiesCommands
CommandsCommands
CommandsCommands
Commands
Domain Objects
EventsEvents
EventsEvents
EventsEvents
EventsEvents
Domain Objects
CommandsCommands
CommandsCommands
CommandsQueries
Query ObjectsQuery Objects
Domain Data
Snapshot
Snapshot
Snapshot
![Page 21: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/21.jpg)
21
In MongoDB SpeakDomain Objects Query Objects
Query Objects
P
S S
Domain Objects
Replica Set/Sharded Cluster Query Cluster
P
S S
![Page 22: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/22.jpg)
22
Domain Object - Eventpurchase_order = { "ID" : "1222-344-27", "timestamp" : "Wed Oct 19 2016 16:50:27 GMT" "dept" : "Manufacturing", "Purchase From" : { "company" : "ABC Ltd", "company number" : 12345678, "VAT ID" : "773456K", "Address" : { ... } } "line items" : [ { ... }, { ... } ], "VAT" : 540.0 "total price" : 2567.54 "currency" : "Euro", "Supplier Ref" : "YF-27-567", "delivery address" : { ...} }
![Page 23: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/23.jpg)
23
Summary
• Event Sourcing : Capture the state as first class objects• CQRS : Optimise differently for commands and queries• MongoDB ideally suited to build both event store and query store• Use different storage engines depending on use case• The aggregation framework generates summary data
![Page 24: Event sourcing the best ubiquitous pattern you have never heard off](https://reader036.vdocument.in/reader036/viewer/2022062522/58e550891a28ab3a468b6537/html5/thumbnails/24.jpg)