SlideShare a Scribd company logo
Kiki Carter
Enterprise Architect
May 2017
Event Sourcing and CQRS in 20
minutes with Akka & Java 8
Lightbend
Headquarters in
San Francisco &
Lausanne,
Switzerland
>2 million
downloads
Lightbend
Reactive
Platform
Originators of the
Reactive Manifesto
>17,000 signers
Reactive Experts
in 20 Countries
around the globe
About me
Some things I like Some things I don’t like
IG: @thatskiki
Heights
Wild wildlife
Unintentional Sharing
These things
Why are we talking about this
anyway?
Not really *new* buzzwords
Legacy App Modernization
(is a thing again)
Distributed Systems(for real this
time)
A system of
autonomous
collaborative distributed
services
Autonomy
From Greek Auto-nomos:
auto meaning self
nomos meaning law
Leading the
way:
Promise
Theory
Think in Promises
not Obligations
“Autonomy makes information
local, leading to greater certainty
and stability”
- In Search for Certainty by Mark Burgess
No one can tell my story better than
I can…
Obligations diverge into unpredictable outcomes from definite
beginnings ⇒ decreased certainty
Promises converge towards a definite outcome from unpredictable
beginnings ⇒ improved certainty
Decreased Certainty IRL
An Autonomous
Service can only
Promise its own
Behavior
How do we get there? (irl)
Data Center A
eCommerce
server
eCommerce
server
eCommerce
server
Database Database
Data Center B
eCommerce
server
eCommerce
server
eCommerce
server
Database Database
Heritage
Distributed
Systems
Enter Distributed Scaling
User
order
cart
Shop
data
User
order
cart
Shop
data
Scale by “stateless services”
Eat your broccoli!
I’m eating it!
I’m eating it!
I’m eating it!
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
But wait, there’s more!
User
order
cart
Shop
data
User
order
cart
Shop
data
Shareddomainobjs
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
Shareddomainobjs
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
May not be accurate – probably isn’t
It’s not the things, it’s the things
that happen
#facts
Define with events
Example: Instead of a shop
service, events that happen within
the shopping context
What happens to our state?
First: A true story
Enter Event Sourcing
Shopping context
data data
events
events
events
Stateless Gateway
entity entity entity
state state state
Akka
Persistence
commands
In Akka Persistence: key structures
Command
Events
State
Events
Events
Inside your persistent Actor:
Anatomy:
Anatomy:
Recovery, a first class concept:
Why bring cqrs along?
The world revolves around events:
command
command
command
eventevent
eventeventevent
event
state Snapshots | Events
Read-side
representation
queries
Read-side
processing
Read-only
command
And if you need to share facts
outside of your context boundary…
command
command
command
eventevent
eventeventevent
event
state Snapshots | Events
distributed
pub-subRead-only
command
Read-side
representation
queries
Read-side
processing
Service A Service B
Technology Implications
• The storage system becomes an additive only architecture
• Append-only architectures distribute
• Far fewer locks to deal with
• Horizontal Partitioning is difficult for a relational model
Business Implications
• Criteria is tracked from inception as an event stream
• You can answer questions form the origin of the system
• You can answer questions not asked yet!
• Natural audit log
Questions?
An Open Source framework for building micro service systems
Rate of change with levels of
abstraction
Low level languages
High level languages
Libraries / packages
Application Frameworks
Application Networking
System Building Frameworks
Rate of change Levels of abstraction
Shopping context
data data
events
events
events
Stateless Gateway
entity entity entity
state state state
Akka
Persistence
is focused
in the entity
commands
Web Application Framework
Concurrency Toolkit  Runtime
Thin, powerful abstraction over
Microservice system framework
Other curated tools,
architectural
principles and
patterns used for
building reactive
microservice systems
Enterprise Challenge
Build faster
Maintain architectural integrity as you move fast
Enterprise software development is a high stakes game
Success is high reward, failure is high risk
Too Many Choices
Analysis Paralysis
Challenge
Lagom makes reasonable choices for
you.
It’s built on message-driven technology
that’s highly responsive, elastic and fault-
tolerant.
It’s Reactive.
Lagom Components
Akka – Persistence, PubSub, Cluster, Streaming Async Services
Play Framework – Web framework
Cassandra – managing data persistence
Guice – dependency injection
SLF4J & Logback – Logging
Typesafe Config – configuration
JSON Serialization – Play JSON (Scala) Jackson (Java)
Service Gateway
Message Broker - Kafka
Difficult to Consistently Scale
Architectural Integrity
Challenge
Lagom consistently applies
patterns for Reactive System
Building
Architectural Principles Enforced by Lagom
Single Responsibility
Principle
Service Oriented
Architecture
Encapsulation
Hexagonal
Architecture
Asynchronous
& Non
Blocking
Event
Sourcing
Command
query
responsibility
segregation
Eventual
Consistency
Domain
Driven Design
(Bounded Contexts,
Context Maps, Aggregate
Entities)
Service
Locator
Discovery
Edge Service
Lagom Design Patterns
Key Patterns
Required
when building
distributed
reactive
microservice
systems
Circuit
Breaker
Example: Event Sourcing
Experts Required
Challenge
Experts Required
You don’t need “Lagom developers” just Scala or Java developers
willing to apply Lagom semantics.
Must Protect Developer
Productivity
Challenge
Practical Productivity
Scala
&
Java API
Use Any IDE
Quick Start
w/ Batteries
Included
Hot Reload
& Single
Command
to Runall
Developer
productivity
is a core
feature of
the
Framework
Unplanned Complexity or Chaos
Challenge
Monolith
with many
moving
parts.
You cannot simply
break the seal and
expect everything
to function correctly
Lagom minimizes chaos through
isolation, autonomous services
Lagom Encourages and Enables
You to Contain Mutable State &
Publish Facts
Example:
State contained
Publish Facts
Lagom Allows You to Untangle
Read & Write Models with CQRS &
Event Sourcing
Lagom uses asynchronous
messaging, asynchronous IO &
distributed persistence patterns
client
command
command
node
node
node
node
Reactive programming
RES
T
messaging streaming
Stateless Behavior
node
Reactive programming
Stateful Entity
Write model
event log
DS
Event
(fact)
Event
(fact)
Read model
query db
DS
Event
(fact)
Event
(fact)
Service
discovery
Service
gateway
Authentication
…
command
command
command
ReactiveSystem
All or Nothing
This and Everything
Challenge
Event Sourcing in less than 20 minutes - With Akka and Java 8
Lagom & your Legacy
• Language agnostic communication with external services
• Safe Interaction with legacy systems via circuit breakers
• No need to tear everything down and start over
• Embraces polyglot systems
With Withoutor
Governance, Templates, Ref Apps,
Documentation, scaling architecture
expertise, etc.
Boot
Reactor
Kafka
Cassandra
Netflix
Patterns
asynchronous REST
streaming CQRS
Event Sourcing
Eventual consistency
DDD
Service locator
Java
Eventuate
Axon
Spring Cloud
…
Play
Akka
Kafka
CassandraScala
Patterns
asynchronous REST
streaming CQRS
Event Sourcing
Eventual consistency
DDD
Service locator
Java
In Summary
In order to keep up with the pace of change and
maintain architectural integrity as you move, try
using a framework that provides an abstraction
above the application level – at the system level.
….and what if you don’t?
Try Lagom
• www.lagomframework.com , https://github.com/lagom
• Basic example “Hello World” -
https://www.lagomframework.com/get-started-scala.html
• More robust example “Online Auction” -
https://github.com/lagom/online-auction-scala
• Ask me for a demo:
• kiki@lightbend.com
• Twitter: @kikisworldrace
Questions?

More Related Content

What's hot (20)

PPTX
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
MongoDB
 
PDF
APAC Kafka Summit - Best Of
confluent
 
PPTX
Lessons From HPE: From Batch To Streaming For 20 Billion Sensors With Lightbe...
Lightbend
 
PDF
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
confluent
 
PPTX
20160609 nike techtalks reactive applications tools of the trade
shinolajla
 
PDF
Monitoring MySQL at scale
Ovais Tariq
 
PDF
James Watters, Pivotal | Kafka Summit NYC 2019 Keynote (Spring Boot+Kafka: Th...
confluent
 
PDF
RedisConf18 - Transforming Vulnerability Telemetry with Redis Enterprise
Redis Labs
 
PPTX
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Lucas Jellema
 
PDF
Scalable and Reliable Logging at Pinterest
Krishna Gade
 
PPTX
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
PDF
Avoiding the Pit of Despair - Event Sourcing with Akka and Cassandra
Luke Tillman
 
PPTX
Apache Kafka and the Data Mesh | Ben Stopford and Michael Noll, Confluent
HostedbyConfluent
 
PPTX
Building a system for machine and event-oriented data with Rocana
Treasure Data, Inc.
 
PPTX
Webinar | Building Apps with the Cassandra Python Driver
DataStax Academy
 
PDF
What is happening with my microservices?
Israel Blancas
 
PDF
CQRS and Event Sourcing with MongoDB and PHP
Davide Bellettini
 
PPTX
Understanding Codenvy - for Containerized Developer Workspaces
Lynn Langit
 
PDF
Working and Features of HTML5 and PhoneGap - An Overview
Blazeclan Technologies Private Limited
 
PDF
Neha Narkhede | Kafka Summit London 2019 Keynote | Event Streaming: Our Cloud...
confluent
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
MongoDB
 
APAC Kafka Summit - Best Of
confluent
 
Lessons From HPE: From Batch To Streaming For 20 Billion Sensors With Lightbe...
Lightbend
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
confluent
 
20160609 nike techtalks reactive applications tools of the trade
shinolajla
 
Monitoring MySQL at scale
Ovais Tariq
 
James Watters, Pivotal | Kafka Summit NYC 2019 Keynote (Spring Boot+Kafka: Th...
confluent
 
RedisConf18 - Transforming Vulnerability Telemetry with Redis Enterprise
Redis Labs
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Lucas Jellema
 
Scalable and Reliable Logging at Pinterest
Krishna Gade
 
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
Avoiding the Pit of Despair - Event Sourcing with Akka and Cassandra
Luke Tillman
 
Apache Kafka and the Data Mesh | Ben Stopford and Michael Noll, Confluent
HostedbyConfluent
 
Building a system for machine and event-oriented data with Rocana
Treasure Data, Inc.
 
Webinar | Building Apps with the Cassandra Python Driver
DataStax Academy
 
What is happening with my microservices?
Israel Blancas
 
CQRS and Event Sourcing with MongoDB and PHP
Davide Bellettini
 
Understanding Codenvy - for Containerized Developer Workspaces
Lynn Langit
 
Working and Features of HTML5 and PhoneGap - An Overview
Blazeclan Technologies Private Limited
 
Neha Narkhede | Kafka Summit London 2019 Keynote | Event Streaming: Our Cloud...
confluent
 

Similar to Event Sourcing in less than 20 minutes - With Akka and Java 8 (20)

PDF
Deconstructing Monoliths with Domain Driven Design
VMware Tanzu
 
PDF
TDC2017 | São Paulo - Trilha Arquitetura Java How we figured out we had a SRE...
tdc-globalcode
 
PDF
Cloudify your applications: microservices and beyond
Ugo Landini
 
PDF
Cloud Experience: Data-driven Applications Made Simple and Fast
Databricks
 
PDF
Stay productive while slicing up the monolith
Markus Eisele
 
PDF
The Road To Event-Driven Architecture
SheenBrisals
 
PDF
Kalix: Tackling the The Cloud to Edge Continuum
Jonas Bonér
 
PDF
Microservices: Where do they fit within a rapidly evolving integration archit...
Kim Clark
 
PDF
ASAS 2014 - Simon Brown
Avisi B.V.
 
PDF
We are drowning in complexity—can we do better?
Jonas Bonér
 
PDF
Sukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak
 
PDF
Stay productive while slicing up the monolith
Markus Eisele
 
PPTX
Netflix Cloud Architecture and Open Source
aspyker
 
PDF
Microservices Patterns with GoldenGate
Jeffrey T. Pollock
 
PDF
Modernizing Applications with Microservices
Markus Eisele
 
PPTX
What serverless means for enterprise apps
Sumit Sarkar
 
PPTX
apidays LIVE India - Asynchronous and Broadcasting APIs using Kafka by Rohit ...
apidays
 
PDF
CQRS + Event Sourcing
Mike Bild
 
PDF
Internet Scale Architecture
RightScale
 
PDF
Buzzwords: Microservices, containers and serverless - real life applications ...
drnugent
 
Deconstructing Monoliths with Domain Driven Design
VMware Tanzu
 
TDC2017 | São Paulo - Trilha Arquitetura Java How we figured out we had a SRE...
tdc-globalcode
 
Cloudify your applications: microservices and beyond
Ugo Landini
 
Cloud Experience: Data-driven Applications Made Simple and Fast
Databricks
 
Stay productive while slicing up the monolith
Markus Eisele
 
The Road To Event-Driven Architecture
SheenBrisals
 
Kalix: Tackling the The Cloud to Edge Continuum
Jonas Bonér
 
Microservices: Where do they fit within a rapidly evolving integration archit...
Kim Clark
 
ASAS 2014 - Simon Brown
Avisi B.V.
 
We are drowning in complexity—can we do better?
Jonas Bonér
 
Sukumar Nayak-Agile-DevOps-Cloud Management
Sukumar Nayak
 
Stay productive while slicing up the monolith
Markus Eisele
 
Netflix Cloud Architecture and Open Source
aspyker
 
Microservices Patterns with GoldenGate
Jeffrey T. Pollock
 
Modernizing Applications with Microservices
Markus Eisele
 
What serverless means for enterprise apps
Sumit Sarkar
 
apidays LIVE India - Asynchronous and Broadcasting APIs using Kafka by Rohit ...
apidays
 
CQRS + Event Sourcing
Mike Bild
 
Internet Scale Architecture
RightScale
 
Buzzwords: Microservices, containers and serverless - real life applications ...
drnugent
 
Ad

More from J On The Beach (20)

PDF
Massively scalable ETL in real world applications: the hard way
J On The Beach
 
PPTX
Big Data On Data You Don’t Have
J On The Beach
 
PPTX
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
J On The Beach
 
PDF
Pushing it to the edge in IoT
J On The Beach
 
PDF
Drinking from the firehose, with virtual streams and virtual actors
J On The Beach
 
PDF
How do we deploy? From Punched cards to Immutable server pattern
J On The Beach
 
PDF
Java, Turbocharged
J On The Beach
 
PDF
When Cloud Native meets the Financial Sector
J On The Beach
 
PDF
The big data Universe. Literally.
J On The Beach
 
PDF
Streaming to a New Jakarta EE
J On The Beach
 
PDF
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
J On The Beach
 
PDF
Pushing AI to the Client with WebAssembly and Blazor
J On The Beach
 
PDF
Axon Server went RAFTing
J On The Beach
 
PDF
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
J On The Beach
 
PDF
Madaari : Ordering For The Monkeys
J On The Beach
 
PDF
Servers are doomed to fail
J On The Beach
 
PDF
Interaction Protocols: It's all about good manners
J On The Beach
 
PDF
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
J On The Beach
 
PDF
Leadership at every level
J On The Beach
 
PDF
Machine Learning: The Bare Math Behind Libraries
J On The Beach
 
Massively scalable ETL in real world applications: the hard way
J On The Beach
 
Big Data On Data You Don’t Have
J On The Beach
 
Acoustic Time Series in Industry 4.0: Improved Reliability and Cyber-Security...
J On The Beach
 
Pushing it to the edge in IoT
J On The Beach
 
Drinking from the firehose, with virtual streams and virtual actors
J On The Beach
 
How do we deploy? From Punched cards to Immutable server pattern
J On The Beach
 
Java, Turbocharged
J On The Beach
 
When Cloud Native meets the Financial Sector
J On The Beach
 
The big data Universe. Literally.
J On The Beach
 
Streaming to a New Jakarta EE
J On The Beach
 
The TIPPSS Imperative for IoT - Ensuring Trust, Identity, Privacy, Protection...
J On The Beach
 
Pushing AI to the Client with WebAssembly and Blazor
J On The Beach
 
Axon Server went RAFTing
J On The Beach
 
The Six Pitfalls of building a Microservices Architecture (and how to avoid t...
J On The Beach
 
Madaari : Ordering For The Monkeys
J On The Beach
 
Servers are doomed to fail
J On The Beach
 
Interaction Protocols: It's all about good manners
J On The Beach
 
A race of two compilers: GraalVM JIT versus HotSpot JIT C2. Which one offers ...
J On The Beach
 
Leadership at every level
J On The Beach
 
Machine Learning: The Bare Math Behind Libraries
J On The Beach
 
Ad

Recently uploaded (20)

PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Python basic programing language for automation
DanialHabibi2
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 

Event Sourcing in less than 20 minutes - With Akka and Java 8