SlideShare a Scribd company logo
Event SourcingIntro & Challenges
Michael Plöd
innoQ

Principal Consultant
@bitboss
Most current systems
only store the current
state
IncidentRestController
IncidentBusinessService
IncidentDAO
Incident
ID USER_ID DATE TEXT
1 23423 11.03.2014 Maus defekt
2 67454 12.03.2014 EMail Empfang
3 93729 12.03.2014 Monitor defekt
… … … …
Classical Architecture
IncidentRestController
IncidentBusinessService
IncidentDAO
Incident
ID USER_ID DATE TEXT
1 23423 11.03.2014 Maus ist kaputt
2 67454 12.03.2014 EMail Empfang
3 93729 12.03.2014 Monitor defekt
… … … …
Update
The dataset is directly being changed, no
history
1 Audit Log only with extra
effort
2 No replay
3 Snapshots only with extra
effort or via backups
? Issues
Many applications are
working well with the classic
approach
However there are areas
where this approach reaches
it’s limitations
?Reactive
? Responsive
? Resilient
? Elastic
? Message driven
IncidentRestController
IncidentBusinessService
IncidentDAO
Incident
Not quite reactive…
Database
Event Sourcing is an
architectural pattern in
which the state of the
application is being
determined by a
sequence of events
Building Blocks
Applications
Event
Queue
Applications issues
events to a queue
Event
Handler
The Event handler
is processing the
events
Event
Store
The event store is
persisting the
events
An event is something 

that happened in the past
t
jetzt
EventEventEventEventEvent
The names of the Events are
part of the

Ubiquitous Language
D D D
ShipmentDeliveredEvent

CustomerVerifiedEvent
CartCheckedOutEvent
CreateCustomerEvent
WillSaveItemEvent
DoStuffEvent
Code Example
public class CustomerVerifiedEvent {
private String eventId;
private Date eventDate;
private CustomerNumber customerNumber;
private String comment;
public CustomerVerifiedEvent(CustomerNumber custNum, String comment) {
this.customerNumber = cusNum;
this.comment = comment;
this.eventDate = new Date();
}
}
Scope your events on the 

basis of

Aggregates
D D D
An Event is always
immutable
!
The sequence of events in
the queue is also called
Event Stream
tnow
EventEventEventEventEvent
IncidentCreatedEvent



incidentNumber: 1

userNumber: 23423
timestamp: 11.03.2014 12:23:23

text: „Maus defekt“
status: „offen“
Event Stream Example
IncidentTextChangedEvent



incidentNumber: 1

text: „Maus ist Kaputt“
IncidentClosedEvent



incidentNumber: 1

solution: „Neue Maus“
status: „geschlossen“
Let’s reuse the ESB
from the failed SOA
project
NO
NO
NO
!
Prefer dumb pipes
with smart endpoints
as a suitable message
broker architecture
1 Complete rebuild is possible
2 Temporal Queries
3 Event Replay
Well known examples
=

Version Control Systems

or
Database Transaction Logs
The Event Store
has a very high
business value
There is no delete!
!
A delete is
just another
event
IncidentCreatedEvent



incidentNumber: 1

userNumber: 23423
timestamp: 11.03.2014 12:23:23

text: „Maus defekt“
status: „offen“
IncidentChangedEvent



incidentNumber: 1

text: „Maus ist Kaputt“
IncidentClosedEvent



incidentNumber: 1

solution: „Neue Maus“
status: „geschlossen“
IncidentRemovedEvent



incidentNumber: 1

Aren’t there performance
issues attached to this kind of
data storage?
YES!
Application
State
Think about applciation
state
Application
Event
Queue
Event
Handler
Event
Store
Application
State
The application queries
the pre-processed
application state
CQRS
Command
Query
Responsibility
Separation
IncidentSOAPEndpoint
IncidentBusinessService
IncidentDAO
Incident
Business
Model
Client
Incident

DTO
Incident

View

Model
RDBMS
Incident

ER-Model
Netzwerk
Netzwerk
EventHandler EventsEvents
Event Sourcing & CQRS
IncidentCommandEndpoint
IncidentCommandService
IncidentCommandDAO
IncidentQueryEndpoint
IncidentQueryService
IncidentQueryDAO
Read Storage
Events
Select * from
Event Store
Event Sourcing is an
interesting architectural
option. However there
are various challanges,
that have to be taken care
of
1 Consistency
2 Validation
3 Parallel Updates
YES
!
Systems based on
CQRS and Event
Sourcing are
mostly eventually
consistent
EventHandler EventsEvents
Eventual Consistency
IncidentCommandEndpoint
IncidentCommandService
IncidentCommandDAO
IncidentQueryEndpoint
IncidentQueryService
IncidentQueryDAO
Read Storage
Events
Select * from
Event Store
BUT
!
You can build a 

fully consistent
system which
follows Event
Sourcing
principles
EventHandler
EventsEvents
Full Consistency
IncidentCommandEndpoint
IncidentCommandService
IncidentCommandDAO
IncidentQueryEndpoint
IncidentQueryService
IncidentQueryDAO
Read Storage
Events
Select * from
Event Store
Your business domain drives
the level of consistency not
technology

Deeper Insight
D D D
Increased (but still
eventual) consistency
EventHandler
EventsEvents
IncidentCommandEndpoint
IncidentCommandService
IncidentCommandDAO
IncidentQueryEndpoint
IncidentQueryService
IncidentQueryDAO
Read Storage
Events
Select * from
Event Store
async
! There is no
standard solution
1 Consistency
2 Validation
3 Parallel Updates
Example Domain
User

Guid id
String email
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent



Guid id
Date timestamp
String email
String password
EmailChangedEvent



Guid userId
Date timestamp
String email
We process 2 million+
registrations per day. A user
can change her email address.
However the emails address
must be unique
?
How high is the
probability that a
validation fails
Which data is required
for the validation
Where is the required
data stored
$
What is the business
impact of a failed
validation that is not
recognized due to
eventual consistency
and how high is the
probability of failure
Your business domain drives
the level of consistency

Deeper Insight
D D D
1 Validate from Event Store
2 Validate from Read Store
3 Perform Validation in
Event Handler
EventHandler EventsEvents
Validation
IncidentCommandEndpoint
IncidentCommandService
IncidentCommandDAO
IncidentQueryEndpoint
IncidentQueryService
IncidentQueryDAO
Read Storage
Events
Select * from
Event Store
1 Consistency
2 Validation
3 Parallel Updates
Example Domain
User

Guid id
String email
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent



Guid id
Date timestamp
String email
String password
EmailChangedEvent



Guid userId
Date timestamp
String email
What happens when
Alice and Bob share an
account and both update the
email address at the same
time
?
What would we do in
a
„classic old school
architecture“
UserRestController
UserBusinessService
UserDAO
User
ID EMAIL PASSWORD
… … …
2341 alice_bob@xyz.com lksjdaslkdjas
… … …
Update
Pessimistic or optimistic locking
Your business domain drives
the locking quality

Deeper Insight
D D D
!
Pessimistic
locking on a
data-level will
hardly work in
event sourcing
architectures
EventHandler
EventsEvents
Where to „pessimistically“ lock?
Read Storage
Events
Event Store
UserRestController
UserBusinessService
UserDAO
User
Commands
Consider a business lock
with a UserLockedEvent
?
Do you

REALLY
need a full lock
Most
„classic architecture“
applications are already
running fine with
optimistic locks
Introduce a version field
for the domain entity
User

Guid id
Long version
String email
String password
RegisterUserCommand ChangeEmailCommand
UserRegisteredEvent



Guid id
Date timestamp
String email
String password
EmailChangedEvent



Guid userId
Date timestamp
String email
Long version
Each writing event
increases the version
UserRegisteredEvent
{guid: 12, version: 0,

email: alicebob@xyz.com, password: werwe2343}
EmailChangedEvent
version: 0
EmailChangedEvent
version: 1
EmailChangedEvent
version: 1
{guid: 12, version: 1,

email: alice_bob@xyz.com, password: werwe2343}
{guid: 12, version: 2,

email: alice@xyz.com, password: werwe2343}
EmailChangeFailedEvent
Also here:

you should be as
consistent as
your domain
requires
Thanks!
Michael Plöd
https://www.innoq.com/de/trainings/microservices-training/
@bitboss
http://slideshare.net/mploed
michael.ploed@innoq.com

More Related Content

PPTX
CQRS and Event Sourcing
PDF
A visual introduction to Event Sourcing and CQRS
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
PPTX
Process Mining and AI for Continuous Process Improvement
PDF
Saturn 2018: Managing data consistency in a microservice architecture using S...
PPTX
Complex architectures for authentication and authorization on AWS
PDF
Microservice Architecture with CQRS and Event Sourcing
PDF
JSON Data Modeling in Document Database
CQRS and Event Sourcing
A visual introduction to Event Sourcing and CQRS
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Process Mining and AI for Continuous Process Improvement
Saturn 2018: Managing data consistency in a microservice architecture using S...
Complex architectures for authentication and authorization on AWS
Microservice Architecture with CQRS and Event Sourcing
JSON Data Modeling in Document Database

What's hot (20)

PPTX
Axon Framework, Exploring CQRS and Event Sourcing Architecture
PDF
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
PDF
Event-driven Architecture
PPTX
ExpertsLive NL 2022 - Microsoft Purview - What's in it for my organization?
PPTX
What is an API Gateway?
PDF
AWS Summit Seoul 2023 | SK와 함께하는 AWS Migration Journey & App Modernization 전략
PPTX
Data Quality - Standards and Application to Open Data
PDF
Introduction to Event-Driven Architecture
PDF
Identity and Access Management from Microsoft and Razor Technology
PDF
Introduction to Event Driven Architecture
PDF
Dual write strategies for microservices
PPTX
6. Accelerate your Journey to the Data Intelligence Platform.pptx
PDF
CQRS + Event Sourcing
PDF
Pourquoi Leroy Merlin a besoin d'un Knowledge Graph ?
PPT
Migrating to MongoDB: Best Practices
PPTX
CAP Theorem
PDF
Event Driven Architecture
PPTX
Data Observability.pptx
PDF
AWS DirectConnect 구성 가이드 (김용우) - 파트너 웨비나 시리즈
PPTX
Microsoft Azure Training | Azure Training For Beginners | Azure Tutorial For ...
Axon Framework, Exploring CQRS and Event Sourcing Architecture
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
Event-driven Architecture
ExpertsLive NL 2022 - Microsoft Purview - What's in it for my organization?
What is an API Gateway?
AWS Summit Seoul 2023 | SK와 함께하는 AWS Migration Journey & App Modernization 전략
Data Quality - Standards and Application to Open Data
Introduction to Event-Driven Architecture
Identity and Access Management from Microsoft and Razor Technology
Introduction to Event Driven Architecture
Dual write strategies for microservices
6. Accelerate your Journey to the Data Intelligence Platform.pptx
CQRS + Event Sourcing
Pourquoi Leroy Merlin a besoin d'un Knowledge Graph ?
Migrating to MongoDB: Best Practices
CAP Theorem
Event Driven Architecture
Data Observability.pptx
AWS DirectConnect 구성 가이드 (김용우) - 파트너 웨비나 시리즈
Microsoft Azure Training | Azure Training For Beginners | Azure Tutorial For ...
Ad

Viewers also liked (6)

PDF
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
PDF
Reactive Microservice Architecture with Groovy and Grails
PDF
DDD Basics - Context mapping
PPTX
Event storming
PDF
Scalability, Availability & Stability Patterns
PDF
Event Sourcing: Einführung und Best Practices
Developing Event-driven Microservices with Event Sourcing & CQRS (gotoams)
Reactive Microservice Architecture with Groovy and Grails
DDD Basics - Context mapping
Event storming
Scalability, Availability & Stability Patterns
Event Sourcing: Einführung und Best Practices
Ad

Similar to Event Sourcing: Introduction & Challenges (20)

PDF
Building Microservices with Event Sourcing and CQRS
PPTX
Eda on the azure services platform
PPTX
DDD meets CQRS and event sourcing
PPTX
Advance Microservice Patterns - Event Souring , CQRS
PDF
Building Microservices with Scala, functional domain models and Spring Boot -...
PDF
#JaxLondon: Building microservices with Scala, functional domain models and S...
PPTX
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
PPTX
Production debugging web applications
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
PDF
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
PPTX
Greenfield Development with CQRS
PDF
Fluturas presentation @ Big Data Conclave
PDF
CQRS and Event Sourcing with MongoDB and PHP
PDF
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
PDF
Building microservices with Scala, functional domain models and Spring Boot (...
PPT
Optimizing Your SOA with Event Processing
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
PDF
fundamentalsofeventdrivenmicroservices11728489736099.pdf
PPTX
A Throwaway Deck for Cloud Security Essentials 2.0 delivered at RSA 2016
PPTX
DIY guide to runbooks, incident reports, and incident response
Building Microservices with Event Sourcing and CQRS
Eda on the azure services platform
DDD meets CQRS and event sourcing
Advance Microservice Patterns - Event Souring , CQRS
Building Microservices with Scala, functional domain models and Spring Boot -...
#JaxLondon: Building microservices with Scala, functional domain models and S...
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Production debugging web applications
Building and deploying microservices with event sourcing, CQRS and Docker (Ha...
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
Greenfield Development with CQRS
Fluturas presentation @ Big Data Conclave
CQRS and Event Sourcing with MongoDB and PHP
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Building microservices with Scala, functional domain models and Spring Boot (...
Optimizing Your SOA with Event Processing
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
fundamentalsofeventdrivenmicroservices11728489736099.pdf
A Throwaway Deck for Cloud Security Essentials 2.0 delivered at RSA 2016
DIY guide to runbooks, incident reports, and incident response

More from Michael Plöd (11)

PDF
Migrating from Grails 2 to Grails 3
PDF
Caching in Hibernate
PDF
Anatomie von Microservice Landschaften
PDF
Event Sourcing für reaktive Anwendungen
PDF
CQRS basierte Architekturen mit Microservices
PDF
Spring One 2 GX 2014 - CACHING WITH SPRING: ADVANCED TOPICS AND BEST PRACTICES
PDF
Caching - Hintergründe, Patterns und Best Practices
PDF
Warum empfehle ich meinen Kunden das Spring Framework?
PDF
Hibernate Tuning
PDF
Bessere Präsentationen
KEY
Integrating Wicket with Java EE 6
Migrating from Grails 2 to Grails 3
Caching in Hibernate
Anatomie von Microservice Landschaften
Event Sourcing für reaktive Anwendungen
CQRS basierte Architekturen mit Microservices
Spring One 2 GX 2014 - CACHING WITH SPRING: ADVANCED TOPICS AND BEST PRACTICES
Caching - Hintergründe, Patterns und Best Practices
Warum empfehle ich meinen Kunden das Spring Framework?
Hibernate Tuning
Bessere Präsentationen
Integrating Wicket with Java EE 6

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Introduction to Artificial Intelligence
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
history of c programming in notes for students .pptx
PDF
top salesforce developer skills in 2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
medical staffing services at VALiNTRY
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
CHAPTER 2 - PM Management and IT Context
How Creative Agencies Leverage Project Management Software.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Introduction to Artificial Intelligence
Adobe Illustrator 28.6 Crack My Vision of Vector Design
history of c programming in notes for students .pptx
top salesforce developer skills in 2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
medical staffing services at VALiNTRY
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Design an Analysis of Algorithms II-SECS-1021-03
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers

Event Sourcing: Introduction & Challenges