Upload
derek-comartin
View
1.712
Download
3
Tags:
Embed Size (px)
DESCRIPTION
Event Sourcing Tech Talk by Derek Comartin @ Windsor Hackforge
Citation preview
Event Sourcing
@derek_comartinCodeOpinion.com
Agenda● Typical Data Persistence● Overview● Events● Why?● Queries● Drawbacks
Typical Data Persistence
● Maintain current state● Concurrent users, data update conflicts.● Auditing
Overview
● Old concept● Using already (transaction log)● Capture Intent● Event = State Change● Sequence of Events● Append Only
Events
● Describes state change● Past tense● Source of truth● Audit log
Event Stream
Started Shopping
Added T-Shirt
Added Socks
Removed Socks
Added Coupon
EventStartedShopping{
CartId: f5a7f55d-1e33-440c-836c-ea50fc59a274,CustomerId: f98902b3-e8cf-4b7a-b561-5e39a06b5e0c,Date: 2014-01-03 15:36:08,
}
AddedSocksToShoppingCart{
CartId: f5a7f55d-1e33-440c-836c-ea50fc59a274,ProductId: ed00fa0b-6412-4cc6-bbac-14702bfeff3f,Quantity: 1,
}
Why?
● Captures business intent● Transaction & Audit log● Build/Rebuild to any model● Debugging● Integration with other systems
Queries● Generate Read Model from Events● Secondary Data Source required● Eventual Consistency
Started Shopping
Added T-Shirt
Added Socks
Removed Socks
Added Coupon
Any model you can think of!
Cart TableCartId
ProductIdQuantity
Denormalized TableCartId
CustomerNameProductIdQuantity
Price
CQRS/ES
Data StorageDomain Object
Domain Object
Command Handlers
Client
CommandDTO
Message Queue
Read Layer
Facade
QueryDTO
Event Storage
Events
Message Queue Event Handlers
Data Storage
Drawbacks
● Multiple Models / Data Sources● Versioning● Performance● Maturity / Public Knowledge