Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13....
Transcript of Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13....
![Page 1: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/1.jpg)
Event sourcingLars vonk & Bob Forma
in production systems
Tuesday, April 9, 13
![Page 2: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/2.jpg)
Let’s take a look how wecurrently develop software
Tuesday, April 9, 13
![Page 3: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/3.jpg)
Tuesday, April 9, 13
![Page 4: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/4.jpg)
Tuesday, April 9, 13
![Page 5: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/5.jpg)
One model to rule them all
Repor&ng
Mix of concerns
QueryingTransac&ons (commands)
Tuesday, April 9, 13
![Page 6: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/6.jpg)
Tuesday, April 9, 13
![Page 7: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/7.jpg)
How did this Invoice get to status :sent?
Tuesday, April 9, 13
![Page 8: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/8.jpg)
How many items are deleted from the shopping cart just before an order is placed?
How did this Invoice get to status :sent?
Tuesday, April 9, 13
![Page 9: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/9.jpg)
Information is lost
How many items are deleted from the shopping cart just before an order is placed?
How did this Invoice get to status :sent?
Tuesday, April 9, 13
![Page 10: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/10.jpg)
Tuesday, April 9, 13
![Page 11: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/11.jpg)
Tuesday, April 9, 13
![Page 12: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/12.jpg)
Event SourcingCapture all changes to an application state as a sequence of events
martinfowler.com/eeaDev/EventSourcing.html - Martin Fowler
Tuesday, April 9, 13
![Page 13: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/13.jpg)
Or maybe not so different...
Tuesday, April 9, 13
![Page 14: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/14.jpg)
Trivial exampleCurrent state
id amount status recipiented3456f 121 sent [email protected]
Tuesday, April 9, 13
![Page 15: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/15.jpg)
Trivial exampleCurrent state
id amount status recipiented3456f 121 sent [email protected]
Event sourced
id event_type event_jsoned3456f InvoiceCreatedEvent {id:“ed3456f”}ed3456f LineItemAddedEvent {id:“ed3456f”, line_item: {id: 1, amount: 100, vat: 21}}ed3456f InvoiceSentEvent {id:“ed3456f”, to: “[email protected]”}
Tuesday, April 9, 13
![Page 16: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/16.jpg)
Event sourced
id event_type event_jsoned3456f InvoiceCreatedEvent {id:“ed3456f”}ed3456f LineItemAddedEvent {id:“ed3456f”, line_item: {id: 1, amount: 100, vat: 21}}ed3456f LineItemRemovedEvent {id:“ed3456f”, line_item_id: 1}ed3456f LineItemAddedEvent {id:“ed3456f”, line_item: {id: 2, amount: 150, vat: 21}}ed3456f InvoiceSentEvent {id:“ed3456f”, to: “[email protected]”}
How many line items are deleted just before...
Tuesday, April 9, 13
![Page 17: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/17.jpg)
So how do you query stuff?
The One Model To Rule Them All
CommandModel
Query Model
View
write
read
Tuesday, April 9, 13
![Page 18: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/18.jpg)
So how do you query stuff?
CommandModel
Query Model
View
Tuesday, April 9, 13
![Page 19: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/19.jpg)
So how do you query stuff?
CommandModel
Query Model
View
writere
ad
Tuesday, April 9, 13
![Page 20: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/20.jpg)
So how do you query stuff?
CommandModel
Query Model
View
writere
ad
CQRS
Tuesday, April 9, 13
![Page 21: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/21.jpg)
So how do you query stuff?
CommandModel
Query Model
View
write
‘generates using events’
read
CQRS
Tuesday, April 9, 13
![Page 22: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/22.jpg)
Concrete example...
Tuesday, April 9, 13
![Page 23: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/23.jpg)
User
Concrete example...
Tuesday, April 9, 13
![Page 24: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/24.jpg)
User
POST /invoices/:id/send
Controller
Concrete example...
Tuesday, April 9, 13
![Page 25: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/25.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler
Concrete example...
Tuesday, April 9, 13
![Page 26: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/26.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Eventstore
Concrete example...
Tuesday, April 9, 13
![Page 27: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/27.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEventEventstore
load_from_history
Concrete example...
events are in past tense
Tuesday, April 9, 13
![Page 28: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/28.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
load_from_history
InvoiceSentEvent
Concrete example...
events are in past tense
Tuesday, April 9, 13
![Page 29: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/29.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
store
load_from_history
InvoiceSentEvent
Concrete example...
events are in past tense
Tuesday, April 9, 13
![Page 30: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/30.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
store
load_from_history
publish_eventsEventHandler
InvoiceSentEvent
Concrete example...
events are in past tense
Tuesday, April 9, 13
![Page 31: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/31.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
store
load_from_history
publish_eventsEventHandlerView
update
InvoiceSentEvent
Concrete example...
events are in past tense
Tuesday, April 9, 13
![Page 32: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/32.jpg)
Part 1: For the business
Why Event Sourcing
Tuesday, April 9, 13
![Page 33: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/33.jpg)
To capture user intent
Part 1: For the business
Why Event Sourcing
Tuesday, April 9, 13
![Page 34: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/34.jpg)
To capture user intentHistoric informa&on
Part 1: For the business
Why Event Sourcing
Tuesday, April 9, 13
![Page 35: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/35.jpg)
To capture user intentHistoric informa&onStorage decoupling
Part 1: For the business
Why Event Sourcing
Tuesday, April 9, 13
![Page 36: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/36.jpg)
To capture user intentHistoric informa&onStorage decoupling
Part 1: For the business
Why Event Sourcing
Defer decisions
Tuesday, April 9, 13
![Page 37: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/37.jpg)
Part 2: For us nerds
Why Event Sourcing
Tuesday, April 9, 13
![Page 38: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/38.jpg)
Tell, don’t ask
Part 2: For us nerds
Why Event Sourcing
Tuesday, April 9, 13
![Page 39: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/39.jpg)
Tell, don’t askIsolated domain tests
Part 2: For us nerds
Why Event Sourcing
Tuesday, April 9, 13
![Page 40: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/40.jpg)
Tell, don’t askIsolated domain tests
Part 2: For us nerds
Why Event Sourcing
Tuesday, April 9, 13
![Page 41: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/41.jpg)
Debug informa&on
Tell, don’t askIsolated domain tests
Part 2: For us nerds
Why Event Sourcing
Tuesday, April 9, 13
![Page 42: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/42.jpg)
Debug informa&on
Tell, don’t askIsolated domain tests
Part 2: For us nerds
Conflict resolu&on
Why Event Sourcing
Tuesday, April 9, 13
![Page 43: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/43.jpg)
It is not a Silver bullet
Tuesday, April 9, 13
![Page 44: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/44.jpg)
Not for CRUD
It is not a Silver bullet
Tuesday, April 9, 13
![Page 45: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/45.jpg)
Learning curve
Not for CRUD
It is not a Silver bullet
Tuesday, April 9, 13
![Page 46: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/46.jpg)
Learning curve
Not for CRUD
More work to do simple stuff
It is not a Silver bullet
Tuesday, April 9, 13
![Page 47: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/47.jpg)
Financial administra&on systemIntegrates with various systemsWeb-‐based
Case study Freemle.com
Event source approved
Tuesday, April 9, 13
![Page 48: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/48.jpg)
THE INTERNALS
Tuesday, April 9, 13
![Page 49: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/49.jpg)
Stack
Tuesday, April 9, 13
![Page 50: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/50.jpg)
Domain
Invoice
Organization
ExpenseCustomer
Bank
Invoice numbers
Ledger
Tuesday, April 9, 13
![Page 51: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/51.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
store
load_from_history
publish_eventsEventHandlerView
update
InvoiceSentEvent
events are in past tense
Remember this picture?
Tuesday, April 9, 13
![Page 52: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/52.jpg)
User wants to mark an invoice as paid
Tuesday, April 9, 13
![Page 53: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/53.jpg)
Request is translated to specific command
Tuesday, April 9, 13
![Page 54: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/54.jpg)
Propagates to correct Domain object
Tuesday, April 9, 13
![Page 55: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/55.jpg)
Retrieves all events for Aggregate
Tuesday, April 9, 13
![Page 56: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/56.jpg)
What does an event look like?
Tuesday, April 9, 13
![Page 57: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/57.jpg)
Rebuild yourself from history
Tuesday, April 9, 13
![Page 58: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/58.jpg)
Events are applied
Tuesday, April 9, 13
![Page 59: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/59.jpg)
Propagates to correct Domain object
Tuesday, April 9, 13
![Page 60: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/60.jpg)
Tell the invoice it has been paid
Tuesday, April 9, 13
![Page 61: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/61.jpg)
Apply events on yourself
Tuesday, April 9, 13
![Page 62: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/62.jpg)
Update your state
Tuesday, April 9, 13
![Page 63: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/63.jpg)
Commit the events in the EventStore
Tuesday, April 9, 13
![Page 64: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/64.jpg)
Publish the events to registered Handlers
Tuesday, April 9, 13
![Page 65: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/65.jpg)
Update view model
Tuesday, April 9, 13
![Page 66: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/66.jpg)
Render view
Tuesday, April 9, 13
![Page 67: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/67.jpg)
User
POST /invoices/:id/send
Controller
SendInvoiceCommand
CommandHandler load_aggregate
Invoice
InvoiceCreatedEvent
LineItemAddedEvent
send
Eventstore
store
load_from_history
publish_eventsEventHandlerView
update
InvoiceSentEvent
events are in past tense
Summary
Tuesday, April 9, 13
![Page 68: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/68.jpg)
EXAMPLE HISTORIC INTEL
Tuesday, April 9, 13
![Page 69: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/69.jpg)
Introducing the timeline
Tuesday, April 9, 13
![Page 70: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/70.jpg)
What was easy?
Tuesday, April 9, 13
![Page 71: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/71.jpg)
Querying (separate model)
What was easy?
Tuesday, April 9, 13
![Page 72: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/72.jpg)
Querying (separate model)Implemen&ng business logic
What was easy?
Tuesday, April 9, 13
![Page 73: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/73.jpg)
Querying (separate model)Implemen&ng business logicMeasuring feature usage
What was easy?
Tuesday, April 9, 13
![Page 74: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/74.jpg)
Querying (separate model)Implemen&ng business logicMeasuring feature usage
What was easy?
Read performance (op&mized view model)
Tuesday, April 9, 13
![Page 75: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/75.jpg)
Querying (separate model)Implemen&ng business logicMeasuring feature usage
What was easy?
Read performance (op&mized view model)No BDUF for the data model
Tuesday, April 9, 13
![Page 76: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/76.jpg)
What was hard?
Tuesday, April 9, 13
![Page 77: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/77.jpg)
What was hard?Mental model change (thinking in events)
Tuesday, April 9, 13
![Page 78: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/78.jpg)
Event upcas&ng
What was hard?Mental model change (thinking in events)
Tuesday, April 9, 13
![Page 79: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/79.jpg)
Defining events
Event upcas&ng
What was hard?Mental model change (thinking in events)
Tuesday, April 9, 13
![Page 80: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/80.jpg)
Open challenges
Tuesday, April 9, 13
![Page 81: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/81.jpg)
Open challenges
Replay all events performance
Tuesday, April 9, 13
![Page 82: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/82.jpg)
Open challenges
Replay all events performanceReplay all events performance
Tuesday, April 9, 13
![Page 83: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/83.jpg)
Asynchronous view model update
Open challenges
Replay all events performanceReplay all events performance
Tuesday, April 9, 13
![Page 84: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/84.jpg)
Zero down&me deployments
Asynchronous view model update
Open challenges
Replay all events performanceReplay all events performance
Tuesday, April 9, 13
![Page 85: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/85.jpg)
Zero down&me deployments
Scaling
Asynchronous view model update
Open challenges
Replay all events performanceReplay all events performance
Tuesday, April 9, 13
![Page 86: Event sourcing · Event sourcing Lars vonk & Bob Forma in production systems Tuesday, April 9, 13. Let’s take a look how we currently develop software Tuesday, April 9, 13. Tuesday,](https://reader034.fdocuments.in/reader034/viewer/2022050519/5fa3325cc06f1232373e8867/html5/thumbnails/86.jpg)
Questions?
Tuesday, April 9, 13