SlideShare a Scribd company logo
1 of 154
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
1
Hi.
First, A Quick Scenario
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
5
Balance: $100
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
6
Balance: -$100
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
7
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
10
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
11
Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
SPRINGONE2GX
WASHINGTON, DC
Richer Data History
With Event Sourcing
Steve Pember
CTO, ThirdChannel
@svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
• Implementation (Theory)
• Implementation (For Real)
• Any Tools Available?
• Demo
13
What Is Event Sourcing?
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
15
Instead, Store Facts
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
19
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
20
Event: Something Which Has
Occurred In The System
Aggregate: The Object of Events’
Affections
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
23
There is No Delete
THIRDCHANNEL @svpember
Full History of the Aggregates
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
• Optimization: Snapshots
28
THIRDCHANNEL @svpember
• snapshot photo
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
30
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
• Optimization: Snapshots
• Example: Shopping Cart
31
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
34
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
• Optimization: Snapshots
• Example: Shopping Cart
• Transient Objects
35
Objects are Transient Derivatives of Your
Events
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
• Optimization: Snapshots
• Example: Shopping Cart
• Transient Objects
• Natural
38
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
40
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
41
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing
• Alternative Storage Pattern
• Series of Facts
• Aggregates << Events
• Purely Additive
• Optimization: Snapshots
• Example: Shopping Cart
• Transient Objects
• Natural
• DDD & CQRS
42
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Domain Driven Design
• Ubiquitous Language
• Bounded Context
• Domain Events
• Aggregates
• Repositories
44
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
45
–Eric Evans
“Some objects are not defined primarily by their attributes. They
represent a thread of identity that runs through time and often
across distinct representations. Sometimes such an object must
be matched with another object even though attributes differ. An
object must be distinguished from other objects even though they
might have the same attributes.”
ES & CQRS can exist separately,
but compliment each other
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Questions So Far?
• Events & Aggregates
• Snapshots
• Additive, loss-less model
• Transient Derivatives
• CQRS / DDD
49
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
50
“I Think I Get What You’re Laying
Down, But It Still Seems Bananas”
So much work!
“That’s gotta be a ton of Resource
overhead”
“Where’d my Models go? I can’t live
without my MVC!”
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing Challenges
• Additional Work To Apply
• Additional CPU Processing
• Non-Traditional Concept of Models
56
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing Challenges
• Additional Work To Apply
• Additional CPU Processing
• Non-Traditional Concept of Models
• More Storage Required VS non-ES
57
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing Challenges
• Additional Work To Apply
• Additional CPU Processing
• Non-Traditional Concept of Models
• More Storage Required VS non-ES
• Reduced Database Level Constraints
59
Make Use of @Transactional
Code
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing Challenges
• Additional Work To Apply
• Additional CPU Processing
• Non-Traditional Concept of Models
• More Storage Required VS non-ES
• Reduced Transactions / Database Level Constraints
• May Be Confusing For Junior Engineers
61
So Why Use ES?
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
63
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
64
Audit Logs Tell the History
Events Tell the Intent of History
ES is also a perfect Audit Log
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
• Data Storage is Inexpensive
68
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
• Data Storage is Inexpensive
• Used By All Long-Running Businesses
69
THIRDCHANNEL @svpember
All Business Problems Can Be Modeled
With Event Sourcing
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
• Data Storage is Inexpensive
• Used By All Long-Running Businesses
• Only Structural Model That Does Not Lose Information
73
Remember: There Is No Delete
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
• Data Storage is Inexpensive
• Used By All Long-Running Businesses
• Only Structural Model That Does Not Lose Information
• Simplified Testing and Debugging
75
Unit Test Events, Assert In Integration
Tests
Time Travel Eases Debugging
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
79
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
81
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
83
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Why Event Sourcing
• More Than an Audit Log
• Data Storage is Inexpensive
• Used By All Long-Running Businesses
• Only Structural Model That Does Not Lose Information
• Simplified Testing and Debugging
• Ideal for Business Analysis
84
Future-Proof your Data
THIRDCHANNEL @svpember
But With Event Sourcing…
–Johnny Appleseed
“Type a quote here.”
THIRDCHANNEL @svpember
Current State is a Projection
A 3C Example
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
93
Still…
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Have you ever built?
• Versioning of objects
• An ‘undo’ action
• Audit Log
• Tracking object value changes over time?
• Time series?
96
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
97
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Querying Events
• All Queries are Projections, including Current State
99
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Querying Events
• All Queries are Projections, including Current State
• Returning Current State is Easy
100
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Querying Events
• All Queries are Projections, including Current State
• Returning Current State is Easy
• Other Projections Can Be Tough, use a Read Model
102
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
103
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Querying Events
• All Queries are Projections, including Current State
• Returning Current State is Easy
• Other Projections Can Be Tough
• Try Reactive Streams
104
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
105
Use Streams to Filter Events in
Code
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
107
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Querying Events
• All Queries are Projections, including Current State
• Returning Current State is Easy
• Other Projections Can Be Tough
• Try Reactive Streams
• Initial Projection Work May Require Dev Time
108
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
109
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
• Implementation (Theory)
110
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Theory)
• Simple Base Objects
111
Three Base Objects
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
113
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
114
Past-Tense Event Names
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
116
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Theory)
• Simple Base Objects
• Aggregate and Event SubClasses Have Transient Properties
117
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Theory)
• Simple Base Objects
• Aggregate and Event SubClasses Have Transient Properties
• Aggregates Receive and Play Events
120
Events Modify Aggregates
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Theory)
• Simple Base Objects
• Aggregate and Event SubClasses Have Transient Properties
• Aggregates Receive and Play Events
• Aggregates Require Distinction Between New and Historical Changes
123
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Theory)
• Simple Base Objects
• Aggregate and Event SubClasses Have Transient Properties
• Aggregates Receive and Play Events
• Aggregates Require Distinction Between New and Historical Changes
• Event Service Layer Required
125
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
• Implementation (Theory)
• Implementation (Reality)
127
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Reality)
• Snapshot Rarely
128
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Reality)
• Snapshot Rarely
• ‘Pure’ Event Sourcing is tough to work with
129
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
130
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Implementation (Reality)
• Snapshot Rarely
• ‘Pure’ Event Sourcing is tough to work with
• 2 Alternatives
131
–Johnny Appleseed
“Type a quote here.”
Sync
–Johnny Appleseed
“Type a quote here.”
Plus so much more (I could talk all
day about ES)
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
• Implementation (Theory)
• Implementation (For Real)
• Any Tools Available?
135
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Source Libraries
• No Real Need for an ORM
136
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Event Sourcing Libraries
• No Real Need for an ORM
• Akka Persistence (JVM)
138
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Persistence & Event Storage
• No Real Need for an ORM
• Akka Persistence (JVM)
• Database Agnostic
139
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
140
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
141
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
142
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
143
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Questions?
144
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
Agenda
• Event Sourcing
• Event Sourcing Challenges
• Don’t Worry, ES Is Worth It
• Querying
• Implementation (Theory)
• Implementation (For Real)
• Any Tools Available?
• Demo?
145
Demo Time!
–Johnny Appleseed
“Type a quote here.”
In Summary
Event Sourcing -> Additive Only,
Lossless. Can Be Tricky To Work
With
Not for your Mom’s Blog
Thank You!
Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
THIRDCHANNEL @svpember
152
Any Questions?
Steve Pember
@svpember
www.thirdchannel.com
THIRDCHANNEL @svpember
More on Event Sourcing
• ThirdChannel Event Source Library (Java): https://github.com/RSV2/eventsource
• Demo App: https://github.com/spember/eventsource-ratpack-reference
• “Event Sourcing” (Martin Fowler): http://martinfowler.com/eaaDev/EventSourcing.html
• Event Store & “Event Sourcing Basics”: http://docs.geteventstore.com/introduction/event-sourcing-basics/
• Event Sourcing presentation by Greg Young: https://www.youtube.com/watch?v=JHGkaShoyNs
• Clarified CQRS: http://udidahan.com/2009/12/09/clarified-cqrs/
THIRDCHANNEL @svpember
Image Credits
• BOA: http://marketmadhouse.com/wp-content/uploads/2014/11/BofA.jpg
• Khaaaaan: http://d1oi7t5trwfj5d.cloudfront.net/38/0d9b80ae5311e1bcc4123138165f92/file/5-things-you-might-not-know-about-star-trek-ii-wrath-of-khan-30th-anniversary.jpg
• tribbles: http://de.memory-alpha.org/wiki/Tribble
• bank ledger: http://www.iowall.net/accounting-ledger-book.html
• ORM: https://guides.codepath.com/android/ActiveAndroid-Guide
• hoarders: http://www.aetv.com/hoarders
• snapshot stream: https://geteventstore.com/
• office space bobs: http://galleryhip.com/office-space-bobs.html
• Nye, Obama, Tyson photo: http://en.wikipedia.org/wiki/Selfie
• Printing Press: http://www.directindustry.com/prod/koenig-bauer-ag/offset-printing-presses-high-volume-40462-602574.html
• CQRS: http://udidahan.com/2009/12/09/clarified-cqrs/

More Related Content

Similar to Richer Data History with Event Sourcing (SpringOne 2GX 2015

Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)Reshmi Krishna
 
Data Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationData Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationAlvaro Videla
 
PCF Killed the ITSM Star
PCF Killed the ITSM StarPCF Killed the ITSM Star
PCF Killed the ITSM StarKyle Campos
 
Automating Brownfield Application Modernization on Pivotal Cloud Foundry
Automating Brownfield Application Modernization on Pivotal Cloud FoundryAutomating Brownfield Application Modernization on Pivotal Cloud Foundry
Automating Brownfield Application Modernization on Pivotal Cloud FoundryVMware Tanzu
 
Data Driven Action : A Primer on Data Science
Data Driven Action : A Primer on Data ScienceData Driven Action : A Primer on Data Science
Data Driven Action : A Primer on Data ScienceSrivatsan Ramanujam
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsMatt Stine
 
So You're Up to Your Eyes in Foundations
So You're Up to Your Eyes in FoundationsSo You're Up to Your Eyes in Foundations
So You're Up to Your Eyes in FoundationsVMware Tanzu
 
Cloud Native Key Management
Cloud Native Key ManagementCloud Native Key Management
Cloud Native Key ManagementVMware Tanzu
 
Concourse in the Real World: A Case Study in CI/CD and DevOps
Concourse in the Real World: A Case Study in CI/CD and DevOpsConcourse in the Real World: A Case Study in CI/CD and DevOps
Concourse in the Real World: A Case Study in CI/CD and DevOpsVMware Tanzu
 
Experiences using grails in a Microservice Architecture SpringOne2gx 2014
Experiences using grails in a Microservice Architecture SpringOne2gx 2014Experiences using grails in a Microservice Architecture SpringOne2gx 2014
Experiences using grails in a Microservice Architecture SpringOne2gx 2014Jeff Beck
 
Spring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniSpring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniVMware Tanzu
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...cornelia davis
 
Fast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudFast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudVMware Tanzu
 
Healthy Agile Product Security
Healthy Agile Product SecurityHealthy Agile Product Security
Healthy Agile Product SecurityVMware Tanzu
 
Six Simple Steps to Service Level Objectives (SLOs)
Six Simple Steps to Service Level Objectives (SLOs)Six Simple Steps to Service Level Objectives (SLOs)
Six Simple Steps to Service Level Objectives (SLOs)VMware Tanzu
 
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...VMware Tanzu
 
SpringOne 2GX 2015 - Fullstack Groovy developer
SpringOne 2GX 2015 - Fullstack Groovy developerSpringOne 2GX 2015 - Fullstack Groovy developer
SpringOne 2GX 2015 - Fullstack Groovy developerIván López Martín
 
Teaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesTeaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesVMware Tanzu
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Daniel Woods
 

Similar to Richer Data History with Event Sourcing (SpringOne 2GX 2015 (20)

Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)
 
Data Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring IntegrationData Migration at Scale with RabbitMQ and Spring Integration
Data Migration at Scale with RabbitMQ and Spring Integration
 
PCF Killed the ITSM Star
PCF Killed the ITSM StarPCF Killed the ITSM Star
PCF Killed the ITSM Star
 
Automating Brownfield Application Modernization on Pivotal Cloud Foundry
Automating Brownfield Application Modernization on Pivotal Cloud FoundryAutomating Brownfield Application Modernization on Pivotal Cloud Foundry
Automating Brownfield Application Modernization on Pivotal Cloud Foundry
 
Data Driven Action : A Primer on Data Science
Data Driven Action : A Primer on Data ScienceData Driven Action : A Primer on Data Science
Data Driven Action : A Primer on Data Science
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring Applications
 
So You're Up to Your Eyes in Foundations
So You're Up to Your Eyes in FoundationsSo You're Up to Your Eyes in Foundations
So You're Up to Your Eyes in Foundations
 
Cloud Native Key Management
Cloud Native Key ManagementCloud Native Key Management
Cloud Native Key Management
 
Concourse in the Real World: A Case Study in CI/CD and DevOps
Concourse in the Real World: A Case Study in CI/CD and DevOpsConcourse in the Real World: A Case Study in CI/CD and DevOps
Concourse in the Real World: A Case Study in CI/CD and DevOps
 
Experiences using grails in a Microservice Architecture SpringOne2gx 2014
Experiences using grails in a Microservice Architecture SpringOne2gx 2014Experiences using grails in a Microservice Architecture SpringOne2gx 2014
Experiences using grails in a Microservice Architecture SpringOne2gx 2014
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud Gateway
 
Spring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane MaldiniSpring Cloud Gateway - Stéphane Maldini
Spring Cloud Gateway - Stéphane Maldini
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
 
Fast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the CloudFast 5 Things You Can Do Now to Get Ready for the Cloud
Fast 5 Things You Can Do Now to Get Ready for the Cloud
 
Healthy Agile Product Security
Healthy Agile Product SecurityHealthy Agile Product Security
Healthy Agile Product Security
 
Six Simple Steps to Service Level Objectives (SLOs)
Six Simple Steps to Service Level Objectives (SLOs)Six Simple Steps to Service Level Objectives (SLOs)
Six Simple Steps to Service Level Objectives (SLOs)
 
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...
Continuous Delivery for Microservice Architectures with Concourse & Cloud Fou...
 
SpringOne 2GX 2015 - Fullstack Groovy developer
SpringOne 2GX 2015 - Fullstack Groovy developerSpringOne 2GX 2015 - Fullstack Groovy developer
SpringOne 2GX 2015 - Fullstack Groovy developer
 
Teaching TDD to Different Learning Styles
Teaching TDD to Different Learning StylesTeaching TDD to Different Learning Styles
Teaching TDD to Different Learning Styles
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015
 

More from Steve Pember

Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Steve Pember
 
SACon 2019 - Surviving in a Microservices Environment
SACon 2019 - Surviving in a Microservices EnvironmentSACon 2019 - Surviving in a Microservices Environment
SACon 2019 - Surviving in a Microservices EnvironmentSteve Pember
 
Surviving in a Microservices environment -abridged
Surviving in a Microservices environment -abridgedSurviving in a Microservices environment -abridged
Surviving in a Microservices environment -abridgedSteve Pember
 
Gradle Show and Tell
Gradle Show and TellGradle Show and Tell
Gradle Show and TellSteve Pember
 
Greach 2018: Surviving Microservices
Greach 2018: Surviving MicroservicesGreach 2018: Surviving Microservices
Greach 2018: Surviving MicroservicesSteve Pember
 
Reactive All the Way Down the Stack
Reactive All the Way Down the StackReactive All the Way Down the Stack
Reactive All the Way Down the StackSteve Pember
 
Event storage in a distributed system
Event storage in a distributed systemEvent storage in a distributed system
Event storage in a distributed systemSteve Pember
 
Harnessing Spark and Cassandra with Groovy
Harnessing Spark and Cassandra with GroovyHarnessing Spark and Cassandra with Groovy
Harnessing Spark and Cassandra with GroovySteve Pember
 
Surviving in a microservices environment
Surviving in a microservices environmentSurviving in a microservices environment
Surviving in a microservices environmentSteve Pember
 
Surviving in a Microservices Environment
Surviving in a Microservices EnvironmentSurviving in a Microservices Environment
Surviving in a Microservices EnvironmentSteve Pember
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...Steve Pember
 
An Introduction to jOOQ
An Introduction to jOOQAn Introduction to jOOQ
An Introduction to jOOQSteve Pember
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRSSteve Pember
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMSteve Pember
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 
Springone2gx 2015 Reactive Options for Groovy
Springone2gx 2015  Reactive Options for GroovySpringone2gx 2015  Reactive Options for Groovy
Springone2gx 2015 Reactive Options for GroovySteve Pember
 
Gr8conf US 2015 - Intro to Event Sourcing with Groovy
Gr8conf US 2015 - Intro to Event Sourcing with GroovyGr8conf US 2015 - Intro to Event Sourcing with Groovy
Gr8conf US 2015 - Intro to Event Sourcing with GroovySteve Pember
 
Gr8conf US 2015: Reactive Options for Groovy
Gr8conf US 2015: Reactive Options for GroovyGr8conf US 2015: Reactive Options for Groovy
Gr8conf US 2015: Reactive Options for GroovySteve Pember
 
Groovy Options for Reactive Applications - Greach 2015
Groovy Options for Reactive Applications - Greach 2015Groovy Options for Reactive Applications - Greach 2015
Groovy Options for Reactive Applications - Greach 2015Steve Pember
 

More from Steve Pember (20)

Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
SACon 2019 - Surviving in a Microservices Environment
SACon 2019 - Surviving in a Microservices EnvironmentSACon 2019 - Surviving in a Microservices Environment
SACon 2019 - Surviving in a Microservices Environment
 
Surviving in a Microservices environment -abridged
Surviving in a Microservices environment -abridgedSurviving in a Microservices environment -abridged
Surviving in a Microservices environment -abridged
 
Gradle Show and Tell
Gradle Show and TellGradle Show and Tell
Gradle Show and Tell
 
Greach 2018: Surviving Microservices
Greach 2018: Surviving MicroservicesGreach 2018: Surviving Microservices
Greach 2018: Surviving Microservices
 
Reactive All the Way Down the Stack
Reactive All the Way Down the StackReactive All the Way Down the Stack
Reactive All the Way Down the Stack
 
Event storage in a distributed system
Event storage in a distributed systemEvent storage in a distributed system
Event storage in a distributed system
 
Harnessing Spark and Cassandra with Groovy
Harnessing Spark and Cassandra with GroovyHarnessing Spark and Cassandra with Groovy
Harnessing Spark and Cassandra with Groovy
 
Surviving in a microservices environment
Surviving in a microservices environmentSurviving in a microservices environment
Surviving in a microservices environment
 
Surviving in a Microservices Environment
Surviving in a Microservices EnvironmentSurviving in a Microservices Environment
Surviving in a Microservices Environment
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...
 
An Introduction to jOOQ
An Introduction to jOOQAn Introduction to jOOQ
An Introduction to jOOQ
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVM
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 
Springone2gx 2015 Reactive Options for Groovy
Springone2gx 2015  Reactive Options for GroovySpringone2gx 2015  Reactive Options for Groovy
Springone2gx 2015 Reactive Options for Groovy
 
Gr8conf US 2015 - Intro to Event Sourcing with Groovy
Gr8conf US 2015 - Intro to Event Sourcing with GroovyGr8conf US 2015 - Intro to Event Sourcing with Groovy
Gr8conf US 2015 - Intro to Event Sourcing with Groovy
 
Gr8conf US 2015: Reactive Options for Groovy
Gr8conf US 2015: Reactive Options for GroovyGr8conf US 2015: Reactive Options for Groovy
Gr8conf US 2015: Reactive Options for Groovy
 
Groovy Options for Reactive Applications - Greach 2015
Groovy Options for Reactive Applications - Greach 2015Groovy Options for Reactive Applications - Greach 2015
Groovy Options for Reactive Applications - Greach 2015
 

Recently uploaded

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 

Recently uploaded (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Richer Data History with Event Sourcing (SpringOne 2GX 2015

  • 1. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 1 Hi.
  • 2. First, A Quick Scenario
  • 3.
  • 4.
  • 5. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 5 Balance: $100
  • 6. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 6 Balance: -$100
  • 7. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 7
  • 9.
  • 10. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 10
  • 11. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 11
  • 12. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attributio n-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ SPRINGONE2GX WASHINGTON, DC Richer Data History With Event Sourcing Steve Pember CTO, ThirdChannel @svpember
  • 13. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying • Implementation (Theory) • Implementation (For Real) • Any Tools Available? • Demo 13
  • 14. What Is Event Sourcing?
  • 15. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern 15
  • 16.
  • 18.
  • 19. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 19
  • 20. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events 20
  • 21. Event: Something Which Has Occurred In The System
  • 22. Aggregate: The Object of Events’ Affections
  • 23. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive 23
  • 24. There is No Delete
  • 26. Full History of the Aggregates
  • 28. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive • Optimization: Snapshots 28
  • 30. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 30
  • 31. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive • Optimization: Snapshots • Example: Shopping Cart 31
  • 34. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 34
  • 35. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive • Optimization: Snapshots • Example: Shopping Cart • Transient Objects 35
  • 36.
  • 37. Objects are Transient Derivatives of Your Events
  • 38. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive • Optimization: Snapshots • Example: Shopping Cart • Transient Objects • Natural 38
  • 39.
  • 40. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 40
  • 41. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 41
  • 42. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing • Alternative Storage Pattern • Series of Facts • Aggregates << Events • Purely Additive • Optimization: Snapshots • Example: Shopping Cart • Transient Objects • Natural • DDD & CQRS 42
  • 43.
  • 44. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Domain Driven Design • Ubiquitous Language • Bounded Context • Domain Events • Aggregates • Repositories 44
  • 45. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 45
  • 46. –Eric Evans “Some objects are not defined primarily by their attributes. They represent a thread of identity that runs through time and often across distinct representations. Sometimes such an object must be matched with another object even though attributes differ. An object must be distinguished from other objects even though they might have the same attributes.”
  • 47.
  • 48. ES & CQRS can exist separately, but compliment each other
  • 49. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Questions So Far? • Events & Aggregates • Snapshots • Additive, loss-less model • Transient Derivatives • CQRS / DDD 49
  • 50. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges 50
  • 51. “I Think I Get What You’re Laying Down, But It Still Seems Bananas”
  • 52.
  • 54. “That’s gotta be a ton of Resource overhead”
  • 55. “Where’d my Models go? I can’t live without my MVC!”
  • 56. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing Challenges • Additional Work To Apply • Additional CPU Processing • Non-Traditional Concept of Models 56
  • 57. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing Challenges • Additional Work To Apply • Additional CPU Processing • Non-Traditional Concept of Models • More Storage Required VS non-ES 57
  • 59. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing Challenges • Additional Work To Apply • Additional CPU Processing • Non-Traditional Concept of Models • More Storage Required VS non-ES • Reduced Database Level Constraints 59
  • 60. Make Use of @Transactional Code
  • 61. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing Challenges • Additional Work To Apply • Additional CPU Processing • Non-Traditional Concept of Models • More Storage Required VS non-ES • Reduced Transactions / Database Level Constraints • May Be Confusing For Junior Engineers 61
  • 62. So Why Use ES?
  • 63. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It 63
  • 64. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log 64
  • 65. Audit Logs Tell the History Events Tell the Intent of History
  • 66.
  • 67. ES is also a perfect Audit Log
  • 68. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log • Data Storage is Inexpensive 68
  • 69. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log • Data Storage is Inexpensive • Used By All Long-Running Businesses 69
  • 71.
  • 72. All Business Problems Can Be Modeled With Event Sourcing
  • 73. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log • Data Storage is Inexpensive • Used By All Long-Running Businesses • Only Structural Model That Does Not Lose Information 73
  • 74. Remember: There Is No Delete
  • 75. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log • Data Storage is Inexpensive • Used By All Long-Running Businesses • Only Structural Model That Does Not Lose Information • Simplified Testing and Debugging 75
  • 76. Unit Test Events, Assert In Integration Tests
  • 77. Time Travel Eases Debugging
  • 78.
  • 79. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 79
  • 80.
  • 81. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 81
  • 82.
  • 83. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 83
  • 84. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Why Event Sourcing • More Than an Audit Log • Data Storage is Inexpensive • Used By All Long-Running Businesses • Only Structural Model That Does Not Lose Information • Simplified Testing and Debugging • Ideal for Business Analysis 84
  • 87.
  • 88. But With Event Sourcing…
  • 91. Current State is a Projection
  • 93. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 93
  • 96. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Have you ever built? • Versioning of objects • An ‘undo’ action • Audit Log • Tracking object value changes over time? • Time series? 96
  • 97. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying 97
  • 98.
  • 99. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Querying Events • All Queries are Projections, including Current State 99
  • 100. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Querying Events • All Queries are Projections, including Current State • Returning Current State is Easy 100
  • 102. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Querying Events • All Queries are Projections, including Current State • Returning Current State is Easy • Other Projections Can Be Tough, use a Read Model 102
  • 103. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 103
  • 104. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Querying Events • All Queries are Projections, including Current State • Returning Current State is Easy • Other Projections Can Be Tough • Try Reactive Streams 104
  • 105. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 105
  • 106. Use Streams to Filter Events in Code
  • 107. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 107
  • 108. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Querying Events • All Queries are Projections, including Current State • Returning Current State is Easy • Other Projections Can Be Tough • Try Reactive Streams • Initial Projection Work May Require Dev Time 108
  • 109. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 109
  • 110. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying • Implementation (Theory) 110
  • 111. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Theory) • Simple Base Objects 111
  • 113. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 113
  • 114. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 114
  • 116. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 116
  • 117. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Theory) • Simple Base Objects • Aggregate and Event SubClasses Have Transient Properties 117
  • 120. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Theory) • Simple Base Objects • Aggregate and Event SubClasses Have Transient Properties • Aggregates Receive and Play Events 120
  • 122.
  • 123. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Theory) • Simple Base Objects • Aggregate and Event SubClasses Have Transient Properties • Aggregates Receive and Play Events • Aggregates Require Distinction Between New and Historical Changes 123
  • 124.
  • 125. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Theory) • Simple Base Objects • Aggregate and Event SubClasses Have Transient Properties • Aggregates Receive and Play Events • Aggregates Require Distinction Between New and Historical Changes • Event Service Layer Required 125
  • 126.
  • 127. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying • Implementation (Theory) • Implementation (Reality) 127
  • 128. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Reality) • Snapshot Rarely 128
  • 129. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Reality) • Snapshot Rarely • ‘Pure’ Event Sourcing is tough to work with 129
  • 130. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 130
  • 131. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Implementation (Reality) • Snapshot Rarely • ‘Pure’ Event Sourcing is tough to work with • 2 Alternatives 131
  • 132. –Johnny Appleseed “Type a quote here.” Sync
  • 133. –Johnny Appleseed “Type a quote here.”
  • 134. Plus so much more (I could talk all day about ES)
  • 135. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying • Implementation (Theory) • Implementation (For Real) • Any Tools Available? 135
  • 136. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Source Libraries • No Real Need for an ORM 136
  • 137.
  • 138. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Event Sourcing Libraries • No Real Need for an ORM • Akka Persistence (JVM) 138
  • 139. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Persistence & Event Storage • No Real Need for an ORM • Akka Persistence (JVM) • Database Agnostic 139
  • 140. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 140
  • 141. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 141
  • 142. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 142
  • 143. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 143
  • 144. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Questions? 144
  • 145. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember Agenda • Event Sourcing • Event Sourcing Challenges • Don’t Worry, ES Is Worth It • Querying • Implementation (Theory) • Implementation (For Real) • Any Tools Available? • Demo? 145
  • 147. –Johnny Appleseed “Type a quote here.”
  • 149. Event Sourcing -> Additive Only, Lossless. Can Be Tricky To Work With
  • 150. Not for your Mom’s Blog
  • 152. Unless otherwise indicated, these slides are © 2013 -2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ THIRDCHANNEL @svpember 152 Any Questions? Steve Pember @svpember www.thirdchannel.com
  • 153. THIRDCHANNEL @svpember More on Event Sourcing • ThirdChannel Event Source Library (Java): https://github.com/RSV2/eventsource • Demo App: https://github.com/spember/eventsource-ratpack-reference • “Event Sourcing” (Martin Fowler): http://martinfowler.com/eaaDev/EventSourcing.html • Event Store & “Event Sourcing Basics”: http://docs.geteventstore.com/introduction/event-sourcing-basics/ • Event Sourcing presentation by Greg Young: https://www.youtube.com/watch?v=JHGkaShoyNs • Clarified CQRS: http://udidahan.com/2009/12/09/clarified-cqrs/
  • 154. THIRDCHANNEL @svpember Image Credits • BOA: http://marketmadhouse.com/wp-content/uploads/2014/11/BofA.jpg • Khaaaaan: http://d1oi7t5trwfj5d.cloudfront.net/38/0d9b80ae5311e1bcc4123138165f92/file/5-things-you-might-not-know-about-star-trek-ii-wrath-of-khan-30th-anniversary.jpg • tribbles: http://de.memory-alpha.org/wiki/Tribble • bank ledger: http://www.iowall.net/accounting-ledger-book.html • ORM: https://guides.codepath.com/android/ActiveAndroid-Guide • hoarders: http://www.aetv.com/hoarders • snapshot stream: https://geteventstore.com/ • office space bobs: http://galleryhip.com/office-space-bobs.html • Nye, Obama, Tyson photo: http://en.wikipedia.org/wiki/Selfie • Printing Press: http://www.directindustry.com/prod/koenig-bauer-ag/offset-printing-presses-high-volume-40462-602574.html • CQRS: http://udidahan.com/2009/12/09/clarified-cqrs/

Editor's Notes

  1. Before I begin, I just want to run through a quick scenario with you all
  2. Picture your bank in your mind. For many of us, this may not exactly be a happy thought. There’s likely several brick and mortar branches for your particular bank in the area. However, being tech folks, I don’t suppose it’s a stretch to surmise that you all primarily interact with your bank via their website, yes?
  3. Imagine you went to your bank’s wonderful website, entered your information, and logged in successfully. I hope no one works for farmers. I typed in “Bank website” into google, and this was the first result.
  4. And, upon logging in, you click the link to check your balance. In doing so, you’re presented with a screen that just shows you “Balance, $100”, but with no context around that number. This may be fine if you expected there to be $100…
  5. What if that’s all your bank balance was, just a simple number? What if that was all your bank could tell you? What if your balance was simply a column in a row in a database somewhere? … and What if you didn’t agree?
  6. How angry would you be? Can you imagine the arguments you’d have with the teller or an agent over the phone, trying to figure out if your latest pay check was deposited?
  7. Luckily, that’s not how things are done. Banks store your account’s entire history. Every transaction you make with your bank. Every Credit or Debit made is logged, along with an audit trail of who (e.g. which teller) made the change. To get your balance, your bank simply adds up each of these transactions May also periodically record what the balance was at specific points in time, to prevent having to recalculate everything from the beginning of time.
  8. There’s a certain advantage to this idea, that we can record all modifications to our data - in this case, the credits and the debits - as EVENTS that occur within our system. For example, Your bank is able to tell you exactly how they arrived at your account balance.
  9. -What about your company’s software? -Can you tell your users or internal business analysts how you are arriving at the data your application presents to them? If they have a disagreement with a value in a … -Today I’m going to present a method called Event Sourcing that does just… that and how it can fuel the competitiveness of your company.
  10. Bold, right? With that, this is ‘Richer Data History with Event Sourcing’. My name is Steve, and I work for a startup called ThirdChannel, which is located in Boston
  11. Today I’d like to go over the following topics: -Event Sourcing at a high level, -Challenges - Querying: “How do I query this mess?”
  12. Let’s begin
  13. Or rather, it’s alternative to your standard ORM storage mapping, Where an object in memory maps directly to a row in a database, even if that row may be split via joins * update is made to a model, updates a column in your database * in this method, the only thing you know about your data is what it looks like right now.
  14. Event Sourcing says “that’s fine, but we’re going to something a bit different”. Instead of storing the current state of our models, we’re going to store facts about our models
  15. Every successful user interaction generates a series of facts or ‘events’ within our system
  16. This stream of events are persisted in our database in the order they occurred, as a journal of what has transpired. These events can then be played back against our Domain Object, building it up to the state it would be at any given point in time, although this is most likely the Current State A stream of events represent a particular object in Aggregate
  17. Which means I should talk about the two main concepts behind Event Sourcing
  18. An Event Represents something that has occurred within your system. The past tense is important when describing them. It represents an intentional user action or result of user action that almost always results in the manipulation or state change or an Object. Things like “BankAccountOpened”, “CurrencyDeposited” are decent names for events
  19. The objects which are affected by Events are referred to as an Aggregate. They generally serve as a root for a stream of events; they represent the state of an event stream ‘in aggregate’. If it helps, you can think of it like a domain model. It doesn’t have to be, though. It can be, say, relationships between objects. For example, at ThirdChannel we model the assignment relationship between our users and what we call programs as an Aggregate. Along with many other things. Note this is a very simple explanation, and I’ll touch more on this later
  20. Event Sourcing is a purely additive model…
  21. there are no deletes or updating of events. Events are immutable once written to our journal This is a powerful notion, if you consider the implications: using Event Sourcing, no data is ever lost or ignored. <pause>
  22. Now, When I need to retrieve information about my Aggregates, I simply play back all of the events that have occurred in the past in order to build up the data to a specific point in time, generally the current date, thus getting the current state of our data.
  23. One of the Key points: by maintaining all events, we’re able to access the current state of our aggregates (again, or objects), certainly, but we can also access the state of our data or aggregates at any point in time. Which is huge.
  24. Now, I’m sure some of you are thinking “waiiit, if I never get rid of anything, certainly that has tradeoffs, too?” Specifically, performance. What happens if I have thousands, or even millions of events I have to apply?
  25. You’re right, and that’s a great observation. Luckily, Event Sourcing recommends an early optimization known as ‘Snapshots’
  26. A Snapshot is just what you’d think it would be: a recording of the details of your Aggregate at that moment in time. Persisted forever
  27. As we consume and create events, periodically we persist a snapshot, containing the state of the aggregate at that point in time. -When replaying events, we load from the most recent snapshot, then apply only the events between when that snapshot was taken, and the targeted end date. So, in this case,… -I’ll get into some more specifics around snapshots in a bit.
  28. One of my favorite examples
  29. Suppose we were building an ecommerce app and we are building the ‘shopping’ cart feature.
  30. Naive, ORM, relational -> join table with quantity Event Sourcing -> <identify page components> are not saved as a join table or a single row.
  31. Instead, w/ ES, system stores all commands you’ve issued / replays for current state <list events> Quickly remove base from the cart, before placing the order and generating an OrderPlacedEvent View doesn’t display raw events Data backing the view is built up from events to form an Object intended for View For those of you familiar with ‘CQRS’, ES is commonly featured as part of it; I’m attempting to describe the ‘Read’ component. Object is Transient -> object will be garbage collected and no direct representation exists on disk
  32. That brings up the next step, Working with Objects
  33. And this is where Event Sourcing will start to hurt your brain. In order to fully grasp what Event Sourcing is, it’s important to realize that…:
  34. All objects that are ‘displayed’ to the user in your View layer are simply transient derivatives of your event stream. They are ephemeral and must be built up from the events to be used in a traditional manner within your application
  35. Finally, I argue that structuring our data in this way is akin to the way our brains work; it’s natural.
  36. Internally, your mind is able to tell you the current state of your knowledge about things. This current state is formed by a series of observations / facts / events in your past. You’re able to replay these events in your mind, and also remember your knowledge at that point in time. Our minds aren’t perfect, though, and sometimes we violate the ES rules by deleting Events. Ooops.
  37. Let’s take me as an Example. Even if you’ve never seen or met me before today, your mind has already recorded a series of facts which is driving your mental model of me. For example: FeatureObservedEvent ActionObservedEvent -Now, if I were to suddenly make a rude gesture at the audience…
  38. that would apply a new event to your mental model. Your current state opinion of me would likely be negative although you could remember a time before you thought negatively of me. “Man, Steve seemed like an alright guy until he flipped off the audience. What a jerk”
  39. Finally, I would be remiss if I didn’t mention Domain Driven Design or CQRS while standing up here talking about Event Sourcing
  40. Has anyone read? Domain Driven Design by Eric Evans?      - Eric wrote this book after years of trying to create  enterprise software      - some great concepts in there…
  41. -Ubiquitous Language -> the domain model the engineers build should be handed down from domain experts. Both the business side of things and the engineers should be able to talk about the system using the same terms and languages. In other words, your engineers should never say ‘AbstractFactory’ to your designers.      -Bounded Context -> keep related models isolated and segregated from the others      -Domain events - something that occurs that domain experts care about      -Aggregates      -Repositories -> each domain object or bounded context should have a dedicated repository for accessing its storage
  42. Earlier I mentioned that you could think of an Aggregate as equivalent to a domain object or an entity… and while you can, the concept of an Aggregate is expressed a bit different in DDD. An Aggregate can be comprised of several ‘internal’ objects which are owned by a ‘parent’ object. This parent object is known as the Aggregate Root. External code touches the Root Aggregate, but cannot link to the Root’s supporting objects
  43. One of the most interesting parts of DDD, one that really stuck with me, is this quote: <read quote> - that’s interesting, yeah?                If I change my name, am I no longer me? Of course not, I’m defined by more than my name. If I change my email address, or my address, or my social security number for some reason, am I no longer me? Obviously not… Can your database understand identity changes like this and still be able to find the original object?                I think this is the heart of Event Sourcing.
  44. not going to spend too much time on this, as CQRS could be it’s own session. I believe there’s a full session dedicated to CQRS later in the conference, so if this seems intriguing, please go. Commands vs Queries      - Write and Read Requests are handled by different objects and different routines within your system. Actual POGO or POJO objects encapsulating your incoming commands and the outing reads      - Ideally, different data repositories      - Event Sourcing tends to go hand in hand with CQRS
  45. -as we’ll see later, some of the terms overlap - in this talk, I explicitly focus on ES, as I think it has a greater
  46. That, I think, is the basis for what Event Sourcing is. It may be a bit early, but are there any questions so far?
  47. Then Let’s move on to the next section, Challenges or Difficulties with ES. Or as I like to call it…
  48. Right now, you may be suspicious. You may be thinking:
  49. “I mean, what you’re describing sounds like a ton of extra work to implement.”
  50. -Not to mention a ton of overhead in processing these events, even if we do make good use of these snapshots you mention
  51. How can you operate in a world without Models?!
  52. And yes, that’s true. *pause* Furthermore, here’s some more bad things:
  53. Storing every event that occurs within your system will almost certainly require more storage space
  54. your database is going to start looking a bit cluttered, and you will repeatedly ask yourself why the heck you keep all this stuff around… who’s going to back and look at all those old books anyway?
  55. Now this is a truly difficult one. - Will have reduced Database Level Constraints, like Foreign Keys, null checks, unique checks, etc. - Instead, we have to rely on our software for transactions and these database constraints
  56. -This is usually where I lose the more seasoned developers. -Because our properties tend to be transients, serialized within the event, we lose things like foreign key constraints at the db level -Instead, in Event Sourcing, these checks tend to move within Transactional blocks within your code. If you’re using Grails or Spring, just slap on an @Transactional annotation
  57. Finally… ES can also be difficult for Junior Engineers I’ve noticed that people really cling to the Model View Controller way of life. - This is a very different way of building our applications, particularly for the web Recommending a different structure for the Model can make people wary. - Telling people that their Views become a “Transient object derived from the event stream” scares them
  58. As crazy as this all might sound, I argue that Event Sourcing actually has huge Benefits
  59. Next Up, “don’t worry, ES is worth it”
  60. First, Going back to the concept of a transaction or an Audit Log… Why is it that I’d want something fancy like ES, when I can audit a log file or look at my transaction log?
  61. There’s a subtle difference between an Audit Log and an Event Stream. Audit logs tell the history of what happened in your system or what was persisted to the database. Events Tell
  62. Furthermore, Having the Events as a first-order member of your platform can give you enhanced information around what your users or systems are doing beyond what might normally get written to the database. Can make events that don’t necessarily deal with the properties changed by a user, but additional actions that may have occurred And it’s easier to work with and analyze the data if the events are integrated within your platform already.
  63. Incidentally, an event object typically should have attached to it information about the user which generated the event, which also makes ES a perfect Audit Log
  64. Data storage is crazy cheap. Last I looked, AWS basic SSD storage was 0.013 per gigabyte hour/ which equates to… If you’re at the point where those pennies matter, you probably have bigger problems.
  65. next. What I find interesting is that Event Sourcing, or a non-digital analogue of it, is used by every ‘mature’, or long running business.
  66. Just Like I went over in the beginning, banks and accounting methods operate with Event Sourcing Bankers additionally even use snapshots of your balance in an additional column beyond credits and debits
  67. Lawyers! If a contract needs to be adjusted, is the contract thrown out and re-written? No. Rather, ‘addendums’ are placed on the contract. To figure out the contract actually involves, one has to read the initial contract, and then each successful addendum in order to figure out what the thing actually says.
  68. In addition, all business problems can be successfully modeled with - and benefit greatly by - event sourcing
  69. How many of you all have delete statements in your code? Even if you don’t, every time you update a row in a database and overwrite some column, you’ve just lost information
  70. Remember: there is no delete, ES is the only structural model which does not lose information.
  71. Event Sourcing simplifies Testing and Debugging. A bold claim, I know.
  72. Testing is easier / simplified with ES, you unit test the events, then later you can simply assert that specific events are applied during integration testing
  73. In addition, debugging is easy, because we have the entire history of our data.
  74. We can look back through our Aggregates’ timelines <next> and examine them at any point in history.
  75. Thus I can see what the historical state of the aggregate… or all my aggregates… was at a particular point in time, along with how it reached that state and who caused those changes.
  76. ahem… I’m sure you’re all keenly aware, but 2015 is the year they visited in this movie. “Where’s my Hoverboard?!” Anyway. If we at some point note that there’s an error or discrepancy in our data…
  77. debugging or tracing the error is a snap -We can find the faulty or conflicting event, know who executed it, when they executed it, and what lead up to the bad state. And then we can emit a new event to ‘patch’ the issue
  78. If we want to get even crazier, we could go to a specific point in our data’s timeline, then fire fake events in order to simulate alternate timelines.
  79. pause This has interesting applications for, say, a.b. testing, stress, and disaster testing. If any of these past few slides reminds you of git… well, how astute. Git is like recursive event sourcing. Ever look at the reflog?
  80. Event sourcing is the ideal storage mechanism for business analysis
  81. -because Event Sourced systems do not lose data, they’re future proofed against any crazy reports that your business analysts may need in the future
  82. suppose one such analyst came to your Ecommerce / shopping cart team asking for… all shoppers who add items to their cart and then remove them within 5 minutes. They want to know who, and which products
  83. with non es, and the naive way I mentioned earlier, you might have to build some sort of tracking table, or mark additional rows with a timestamp.. I dunno. Regardless, then you deploy… and then wait for the data to gather, as users add and remove products
  84. with Event Sourcing, your write a query for that report, you deploy… and then what to do you have? If you’re thinking: all of the data, obviously… well, you’re wrong. You have MORE than everything. We can generate the report for how it would look at every point in our history.
  85. Which makes the company and your business analysts extremely happy. There’s nothing they like better than a good report.
  86. Querying over the events; presenting different Views on them, is often called a projection Perhaps the biggest advantage of ES for me. look at specific events across one stream look at specific event types across all streams I don’t have to query on properties of our domain objects… we can look for patterns in our event stream.
  87. Grabbing the Current State of an aggregate is a projection, and probably the easiest: take all events for an Aggregate, in order. There’s a good deal else to find. In our shopping cart example: find items in cart for any given date or time range find items that were removed for any given date or time range find average rate of items removed vs items purchased for any given… find average duration between items being added and then being removed for any…
  88. Model the relation between our users and the role and state within our platform Can certainly tell you All of the current FMRs or Agents which one of us made those transitions a timeline of each agent’s transition within the program applications with a long gap between entering the system and being wait listed or interviewed, to see how long a candidate waits until we contact them how long on average, an agent lasts before being fired and/or average time for agents that have quit Turnover for a date range And I can tell you that information at ANY POINT IN TIME. e.g. the average quit rate might be different now than 6 months ago, for example that’s all I could think of off the top of my head Which is amazing, right? Just from that one relation. What would happen.. if I started to correlate other event streams?
  89. <Pause> Even after this presentation, if you’re still skeptical of the benefits… and you think this is the silliest thing you’ve ever heard of
  90. ..be aware that the decision can be out of your hands. Event Sourcing is often chosen or driven by Management out of business needs, and ‘hacky’ analogues are shoehorned into an existing system AFTER the fact.
  91. I know I have
  92. And now we get to a particular hairy topic…
  93. How am I going to handle all of these events and find what I’m looking for?
  94. All queries within ES are often referred to as a Projections over the Event Stream. This includes the concept of the current state.
  95. Returning the current state of your aggregates is easy. In other words, a lookup by Id is simple.
  96. Load the aggregate or aggregates by id, load all of the events and replay the events to get back to current state Fairly easy and straightforward
  97. All queries within ES are often referred to as a Projection over the Event Stream. This includes the concept of the current state. Typically when working with relational data, we’ll either say something like “get me the object Foo with id x”, which maps well to the current state of an object.
  98. But not so much with Events, get to this in a minute, but an event is difficult to query Queries like “Find all Foos with active=true and date between 2 values” is easy in standard ‘normal’ form databases. One alternative is a read model maintain a synchronized copy of your aggregates in another table; always sync current state into it, and then query that table Analogous to a database ‘View’ I generally like to keep any data synchronization to a minimum, but this approach can be an attractive convenience for current state searches
  99. In fact, the Event Store database, that’s exactly what they do. One has to write Projections using Streams within a web interface, that then become query-able by clients.
  100. However, as you can probably see. This is fairly difficult. The development team will need to spend time writing the projections. If you have analysts on your team that are used to writing sql, well, it’s going to be much more difficult for them.
  101. Consider feeding events into additional services or tools, particularly those that are stream friendly, like Splunk or Apache Storm
  102. first let’s discuss the theoretical approaches.
  103. Pure Event Sourcing is fairly simplistic in terms of implementation
  104. There’s really only 3 base objects that you have to worry about.
  105. -First up, the Aggregate. You have the id, which should be a UUID, the current revision number, and the type (or ‘clazz’ if you’re working with java) -The current revision number is used for optimistic locking and to see how advanced our aggregate is. -The type is used by our system when we want to load the aggregate into a more meaningful class in the system, say, a SubClass of Aggregate. In our example, the ShoppingCart class would SubClass from Aggregate
  106. Next up, Event -id, revision aggregate_id, the date with time stamp, the type, the user id, and then ‘data’ -data is a serialized representation of the event type’s properties. Generally, JSON, XML, or are recommended for the storage mechanism in the data column. - this could also be a more efficient mechanism, too, like Google’s Protocol Buffers or Apache Avro
  107. All Events should be named in the past tense, as they should reflect something successful that happened in the PAST
  108. Lastly, we have Snapshot. Again, we want to serialize the properties of the aggregate at that moment in time. Next,
  109. I should be clear about what - exactly - is being serialized into those data fields. Aggregates and Events, or at least classes that implement Aggregate and Event, contain, themselves, transient properties which are generally not persisted to the database.
  110. Plain old object with explicit transient properties each has corresponding event or events
  111. The Event itself has transient properties, whose values are persisted to the database. Also, if anyone notices that I’m using JPA annotations and I earlier mentioned that this is an alternative to ORMs… appreciate the irony. This is from a small demo app.
  112. Events Modify Transient values on the Aggregate
  113. It’s almost a Visitor pattern. As Events are generated, they are applied to an Aggregate. Aggregates are built up or, in the case of loading an aggregate, building back up. Event by Event my actual aggregate class may have several properties, however, they are all transient, in the sense that they are not persisted local to the aggregate… e.g. not in the same table. When the aggregate is first created, all of these transients are at their default value, and the playback of the events will restore them to whichever point in time I want.
  114. shopping cart -> Order placement should only charge credit card the first time the event is created
  115. In addition, you’ll also need a service layer to store and load the events and aggregates
  116. it must remember to load events in order of their revision number for the correct aggregate, and initiate the event serialization and de-serialization processes
  117. And those are the basics. That’s not too bad, eh? Unfortunately… there are a few more practical considerations to go over that are a reality for any real ES system.
  118. While snapshots seem awesome, do it only rarely. Greg Young, one of the largest voices in the ES community, claims that he doesn’t snapshot an aggregate until it reaches 1000 events. You have to juggle the time cost of the additional query for the snapshot versus the processing of the small event objects.
  119. While snapshots seem awesome, do it only rarely. Greg Young, one of the largest voices in the ES community, claims that he doesn’t snapshot an aggregate until it reaches 1000 events. You have to juggle the time cost of the additional query for the snapshot versus the processing of the small event objects.
  120. I internally made this slide hard to read to emphasize the point: querying for specific properties within events is tough. See that nice blob of JSON in the data column? As an aside: We use Postgres, which I love, which has two dedicated types for working with JSON. However, I also love JOOQ and JPA, both of which can not work with those types. If anyone knows of a way to get those working with Postgres JSON, please let me know.
  121. While snapshots seem awesome, do it only rarely. Greg Young, one of the largest voices in the ES community, claims that he doesn’t snapshot an aggregate until it reaches 1000 events. You have to juggle the time cost of the additional query for the snapshot versus the processing of the small event objects.
  122. First, the ‘Synced’ pattern. This involves keeping a ‘standard’ synchronized, current state representation of your aggregates. All writes go into the Event log, and then the Domain object is updated. All queries done against the ‘standard’ Domain objects. This is a read model Downside is that you have to do an additional write in sync with your event stream, which can be a pain.
  123. Second, and my preferred pattern, is what I call the ‘Hybrid’ approach   Use multi table inheritance to give each of your aggregates their own table. Add each of the properties you’d like to index or add database level checks, like foreign keys. It doesn’t have to be all the properties. Your aggregate maintains the current state of your data at the db level Now, the advantage of this approach is that I get the benefits of both ES and standard relational. I can make use of the standard relational db querying and indexing, plus each of my aggregates is backed by the event journal
  124. I had originally built this out to enumerate many more items, but then realized that they could be grouped into distinct sections. So, next up…
  125. With the naive use case, here’s my entire schema… our at least, without Snapshot. The snapshot is very similar to aggregate, just with a data text field
  126. These are the ones I’m aware of that are in active development. NVentStore, Prooph, and Akka. Akka is interesting, in that every object you work with is persisted as an event stream, but it doesn’t explicitly call itself Akka Event Source. Of these, I’d probably recommend Akka, provided you’re on the JVM. The persistence component is available as a standalone jar
  127. When looking for a storage mechanism, there many options available to you, and, for the most part, you’ll be fine no matter which database option you choose. Now, here are some of the better options
  128. First, EventStore, the database. Highly specialized for working with events and generating projections. Written By Greg Young, who is perhaps the most well known person in the Event Sourcing community.
  129. A time series database like influxDB is a great choice as an event store
  130. Chiefly intended as a message broker, it also maintains a journal of all your events. I haven’t used it directly, but anytime I start talking about Event Sourcing, someone mentions Kafka. I should really check it out.
  131. And if course, you cannot go wrong with good, old fashioned Relational Databases. I would suggest consider sticking with a standard relation database, if you’re already using it Switching to something like Event Sourcing is already enough change A quick aside.
  132. First, I’d like to point out that we at ThirdChannel have open sourced a small library that we’re using internally for doing Event Sourcing on the JVM. written in Groovy and RxJava
  133. Event Sourcing is an additive only, lossless data storage pattern which has insanely high potential for data analysis. It is, however, tricky to work efficiently with.
  134. I wouldn’t recommend it for certain applications; say small static content information websites (e.g. a restaurant or a business’ marketing site). Nor does it make sense to apply to every domain object in a system. However, key data in your application that you use to drive your business can benefit greatly from this approach.
  135. With that, I say thank you for you coming.