SlideShare a Scribd company logo
1
CQRS & EVENT
SOURCING
With Lagom
2 . 1
Miel Donkers
@mieldonkers
github.com/mdonkers
 
@codecentric_nl
2 . 2
Agenda
CQRS concepts
Event Sourcing concepts
Introduction Lagom framework
CQRS & ES as basis for Lagom
Lagom code / demo
3 . 1
What is CQRS
3 . 2
What is CQRS
Command Query Responsibility Segregation
3 . 3
Traditional Architecture
© Martin Fowler
3 . 4
CQRS Architecture
© Martin Fowler
3 . 5
Storing data
Simple approach
Single database
Normalized tables for write-side data
Views for denormalizing data
Keep queries simple
3 . 6
CQRS related to DDD
DDD - Domain Driven Design
Bounded Context
Aggregate
Command
Event
3 . 7
DDD example
3 . 8
Command - Event - State
3 . 9
Service owns data
4 . 1
What is ES
4 . 2
What is ES
Event Sourcing
Event describes the state change of aggregate
Event is saved in event store
Events can be replayed to re-create the current state.
4 . 3
CQRS & ES Combined
4 . 4
Architecture with Transactions
© Microsoft - CQRS Journey
4 . 5
Architecture with Messages
© Microsoft - CQRS Journey
4 . 6
The hard parts
4 . 7
Consistency
Key feature for the Event Store
Without transactions, much work needed to make as
reliable
Versioning / timestamps
Eventual consistency
4 . 8
Error Handling
Distinguish between business faults and errors.
Errors can be re-tried.
Business faults should have pre-determined
reaction.
4 . 9
Other disadvantages
Many moving parts, makes it hard to debug the
system as a whole
CQRS not for every bounded context
4 . 10
Advantages
4 . 11
Advantages
Auditing and historical tracing
Read and write side can be optimized separately
Debug in local environment
Small components which are easy to update / fix
No ORM impedance mismatch
5 . 1
Lagom microservice framework
5 . 2
Design philosophy
Distributed
Asynchronous
Productivity
5 . 3
Concepts
Microservices
Polyglot
Design Driven APIs
Immutability
Event Sourcing and CQRS
5 . 4
Opiniated
ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> stream();
@Override
default Descriptor descriptor() {
return named("stream").withCalls(namedCall("stream", this::stream))
.withAutoAcl(true);
}
5 . 5
Core technologies
Akka
Akka Streams
Akka Persistence
Akka Cluster
Play
ConductR
5 . 6
Lagom persistence
Cassandra
PersistentEntity
Requires Command, Eventand State
Single instance kept in memory
5 . 7
Command - Event - State
5 . 8
5 . 9
Get me all inspections with remarks for a given ship
Query example
5 . 10
Lagom JDBC support
Available in 1.2 release
Slick
Storing and reading entities
6 . 1
CODE
6 . 27 . 1
Wrapping Up
7 . 2
Lessons learned
Conventions make setup easy
Framework on top of many layers
...
[INFO] Service locator is running at http://localhost:8000
[INFO] Service gateway is running at http://localhost:9000
...
[INFO] (Service started, press enter to stop and go back to the console...)
[error] c.l.l.i.s.ServiceRegistrationModule$RegisterWithServiceRegistry
- Service name=[hello] couldn't register itself to the service locator.
com.lightbend.lagom.javadsl.api.transport.TransportException: <head>
...
[error] a.c.s.PersistentShardCoordinator - Persistence failure when replaying
events for persistenceId [/sharding/HelloEntityCoordinator]. Last
known sequence number [0]
com.lightbend.lagom.javadsl.api.transport.PolicyViolation: <head>
...
7 . 3
7 . 4
Links
Martin Fowler - CQRS
Microsoft - CQRS Journey
Lagom Framework
Miel Donkers - Lagom CQRS Demo
7 . 5
Thank You!
7 . 6
We're hiring

More Related Content

What's hot

Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
Fabrice Sznajderman
 
JEEconf 2017
JEEconf 2017JEEconf 2017
JEEconf 2017
Ihor Kolodyuk
 
Application Deployment and Management at Scale at 1&1
Application Deployment and Management at Scale at 1&1Application Deployment and Management at Scale at 1&1
Application Deployment and Management at Scale at 1&1
Matt Baldwin
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
Markus Eisele
 
Container Patterns
Container PatternsContainer Patterns
Container Patterns
Matthias Luebken
 
Oops! I started a broker | Yinon Kahta, Taboola
Oops! I started a broker | Yinon Kahta, TaboolaOops! I started a broker | Yinon Kahta, Taboola
Oops! I started a broker | Yinon Kahta, Taboola
HostedbyConfluent
 
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
IT Arena
 
Building Cloud Native Applications Using Spring Boot and Spring Cloud
Building Cloud Native Applications Using Spring Boot and Spring CloudBuilding Cloud Native Applications Using Spring Boot and Spring Cloud
Building Cloud Native Applications Using Spring Boot and Spring Cloud
GeekNightHyderabad
 
How Apache Kafka® Works
How Apache Kafka® WorksHow Apache Kafka® Works
How Apache Kafka® Works
confluent
 
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Docker, Inc.
 
Dnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforussoDnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforussoDotNetCampus
 
Levelling up in Akka
Levelling up in AkkaLevelling up in Akka
Levelling up in Akka
Sigmoid
 
Microservices: Another Way
Microservices: Another WayMicroservices: Another Way
Microservices: Another Way
Mykhailo Sorokovskyy
 
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache SparkLightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend
 
How ddd, cqrs and event sourcing constitute the architecture of the future
How ddd, cqrs and event sourcing constitute the architecture of the futureHow ddd, cqrs and event sourcing constitute the architecture of the future
How ddd, cqrs and event sourcing constitute the architecture of the future
MSDEVMTL
 
AKS
AKSAKS
Reactive Architectures
Reactive ArchitecturesReactive Architectures
Reactive Architectures
Ralph Winzinger
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
C2B2 Consulting
 
Kubernetes your tests! automation with docker on google cloud platform
Kubernetes your tests! automation with docker on google cloud platformKubernetes your tests! automation with docker on google cloud platform
Kubernetes your tests! automation with docker on google cloud platform
LivePerson
 

What's hot (19)

Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
 
JEEconf 2017
JEEconf 2017JEEconf 2017
JEEconf 2017
 
Application Deployment and Management at Scale at 1&1
Application Deployment and Management at Scale at 1&1Application Deployment and Management at Scale at 1&1
Application Deployment and Management at Scale at 1&1
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Container Patterns
Container PatternsContainer Patterns
Container Patterns
 
Oops! I started a broker | Yinon Kahta, Taboola
Oops! I started a broker | Yinon Kahta, TaboolaOops! I started a broker | Yinon Kahta, Taboola
Oops! I started a broker | Yinon Kahta, Taboola
 
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
 
Building Cloud Native Applications Using Spring Boot and Spring Cloud
Building Cloud Native Applications Using Spring Boot and Spring CloudBuilding Cloud Native Applications Using Spring Boot and Spring Cloud
Building Cloud Native Applications Using Spring Boot and Spring Cloud
 
How Apache Kafka® Works
How Apache Kafka® WorksHow Apache Kafka® Works
How Apache Kafka® Works
 
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
 
Dnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforussoDnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforusso
 
Levelling up in Akka
Levelling up in AkkaLevelling up in Akka
Levelling up in Akka
 
Microservices: Another Way
Microservices: Another WayMicroservices: Another Way
Microservices: Another Way
 
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache SparkLightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
 
How ddd, cqrs and event sourcing constitute the architecture of the future
How ddd, cqrs and event sourcing constitute the architecture of the futureHow ddd, cqrs and event sourcing constitute the architecture of the future
How ddd, cqrs and event sourcing constitute the architecture of the future
 
AKS
AKSAKS
AKS
 
Reactive Architectures
Reactive ArchitecturesReactive Architectures
Reactive Architectures
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
Kubernetes your tests! automation with docker on google cloud platform
Kubernetes your tests! automation with docker on google cloud platformKubernetes your tests! automation with docker on google cloud platform
Kubernetes your tests! automation with docker on google cloud platform
 

Similar to CQRS and ES with Lagom

Scale and Throughput @ Clicktale with Akka
Scale and Throughput @ Clicktale with AkkaScale and Throughput @ Clicktale with Akka
Scale and Throughput @ Clicktale with Akka
Yuval Itzchakov
 
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
Ceph Community
 
DevOps Course Contents.docx
DevOps Course Contents.docxDevOps Course Contents.docx
DevOps Course Contents.docx
Futurepoint13
 
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
HostedbyConfluent
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at Netflix
Brendan Gregg
 
Oow2007 performance
Oow2007 performanceOow2007 performance
Oow2007 performanceRicky Zhu
 
G rpc talk with intel (3)
G rpc talk with intel (3)G rpc talk with intel (3)
G rpc talk with intel (3)
Intel
 
download it from here
download it from heredownload it from here
download it from herewebhostingguy
 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with Kafka
Andrei Rugina
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
QAware GmbH
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
Mario-Leander Reimer
 
Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2
abramsm
 
OOW09 EBS Tech Essentials
OOW09 EBS Tech EssentialsOOW09 EBS Tech Essentials
OOW09 EBS Tech Essentialsjucaab
 
Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...
IndicThreads
 
Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019
Jovan Popovic
 
Oracle 10g rac_overview
Oracle 10g rac_overviewOracle 10g rac_overview
Oracle 10g rac_overviewRobel Parvini
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
Venkatesh Narayanan
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
phanleson
 
ES and CQRS workshop
ES and CQRS workshopES and CQRS workshop
ES and CQRS workshop
Zeldal Ozdemir
 
GWAB 2015 - Data Plaraform
GWAB 2015 - Data PlaraformGWAB 2015 - Data Plaraform
GWAB 2015 - Data Plaraform
Marcelo Paiva
 

Similar to CQRS and ES with Lagom (20)

Scale and Throughput @ Clicktale with Akka
Scale and Throughput @ Clicktale with AkkaScale and Throughput @ Clicktale with Akka
Scale and Throughput @ Clicktale with Akka
 
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
Ceph Day Seoul - AFCeph: SKT Scale Out Storage Ceph
 
DevOps Course Contents.docx
DevOps Course Contents.docxDevOps Course Contents.docx
DevOps Course Contents.docx
 
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
Give Your Confluent Platform Superpowers! (Sandeep Togrika, Intel and Bert Ha...
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at Netflix
 
Oow2007 performance
Oow2007 performanceOow2007 performance
Oow2007 performance
 
G rpc talk with intel (3)
G rpc talk with intel (3)G rpc talk with intel (3)
G rpc talk with intel (3)
 
download it from here
download it from heredownload it from here
download it from here
 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with Kafka
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2
 
OOW09 EBS Tech Essentials
OOW09 EBS Tech EssentialsOOW09 EBS Tech Essentials
OOW09 EBS Tech Essentials
 
Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...
 
Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019Azure SQL Managed Instance - SqlBits 2019
Azure SQL Managed Instance - SqlBits 2019
 
Oracle 10g rac_overview
Oracle 10g rac_overviewOracle 10g rac_overview
Oracle 10g rac_overview
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
ES and CQRS workshop
ES and CQRS workshopES and CQRS workshop
ES and CQRS workshop
 
GWAB 2015 - Data Plaraform
GWAB 2015 - Data PlaraformGWAB 2015 - Data Plaraform
GWAB 2015 - Data Plaraform
 

More from Miel Donkers

Instana - ClickHouse presentation
Instana - ClickHouse presentationInstana - ClickHouse presentation
Instana - ClickHouse presentation
Miel Donkers
 
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQCQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
Miel Donkers
 
Code reviews and pair programming
Code reviews and pair programmingCode reviews and pair programming
Code reviews and pair programming
Miel Donkers
 
Continuous delivery is not finished
Continuous delivery is not finishedContinuous delivery is not finished
Continuous delivery is not finished
Miel Donkers
 
DevOps presentation at gemeente Rotterdam
DevOps presentation at gemeente RotterdamDevOps presentation at gemeente Rotterdam
DevOps presentation at gemeente Rotterdam
Miel Donkers
 
Successful testing continuous delivery - coding serbia 2013
Successful testing continuous delivery - coding serbia 2013Successful testing continuous delivery - coding serbia 2013
Successful testing continuous delivery - coding serbia 2013Miel Donkers
 
Testing the continuous delivery process @dev opsdays ams 2013
Testing the continuous delivery process   @dev opsdays ams 2013Testing the continuous delivery process   @dev opsdays ams 2013
Testing the continuous delivery process @dev opsdays ams 2013
Miel Donkers
 

More from Miel Donkers (7)

Instana - ClickHouse presentation
Instana - ClickHouse presentationInstana - ClickHouse presentation
Instana - ClickHouse presentation
 
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQCQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
 
Code reviews and pair programming
Code reviews and pair programmingCode reviews and pair programming
Code reviews and pair programming
 
Continuous delivery is not finished
Continuous delivery is not finishedContinuous delivery is not finished
Continuous delivery is not finished
 
DevOps presentation at gemeente Rotterdam
DevOps presentation at gemeente RotterdamDevOps presentation at gemeente Rotterdam
DevOps presentation at gemeente Rotterdam
 
Successful testing continuous delivery - coding serbia 2013
Successful testing continuous delivery - coding serbia 2013Successful testing continuous delivery - coding serbia 2013
Successful testing continuous delivery - coding serbia 2013
 
Testing the continuous delivery process @dev opsdays ams 2013
Testing the continuous delivery process   @dev opsdays ams 2013Testing the continuous delivery process   @dev opsdays ams 2013
Testing the continuous delivery process @dev opsdays ams 2013
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 

CQRS and ES with Lagom

  • 2. 2 . 1 Miel Donkers @mieldonkers github.com/mdonkers   @codecentric_nl
  • 3. 2 . 2 Agenda CQRS concepts Event Sourcing concepts Introduction Lagom framework CQRS & ES as basis for Lagom Lagom code / demo
  • 4. 3 . 1 What is CQRS
  • 5. 3 . 2 What is CQRS Command Query Responsibility Segregation
  • 6. 3 . 3 Traditional Architecture © Martin Fowler
  • 7. 3 . 4 CQRS Architecture © Martin Fowler
  • 8. 3 . 5 Storing data Simple approach Single database Normalized tables for write-side data Views for denormalizing data Keep queries simple
  • 9. 3 . 6 CQRS related to DDD DDD - Domain Driven Design Bounded Context Aggregate Command Event
  • 10. 3 . 7 DDD example
  • 11. 3 . 8 Command - Event - State
  • 12. 3 . 9 Service owns data
  • 13. 4 . 1 What is ES
  • 14. 4 . 2 What is ES Event Sourcing Event describes the state change of aggregate Event is saved in event store Events can be replayed to re-create the current state.
  • 15. 4 . 3 CQRS & ES Combined
  • 16. 4 . 4 Architecture with Transactions © Microsoft - CQRS Journey
  • 17. 4 . 5 Architecture with Messages © Microsoft - CQRS Journey
  • 18. 4 . 6 The hard parts
  • 19. 4 . 7 Consistency Key feature for the Event Store Without transactions, much work needed to make as reliable Versioning / timestamps Eventual consistency
  • 20. 4 . 8 Error Handling Distinguish between business faults and errors. Errors can be re-tried. Business faults should have pre-determined reaction.
  • 21. 4 . 9 Other disadvantages Many moving parts, makes it hard to debug the system as a whole CQRS not for every bounded context
  • 23. 4 . 11 Advantages Auditing and historical tracing Read and write side can be optimized separately Debug in local environment Small components which are easy to update / fix No ORM impedance mismatch
  • 24. 5 . 1 Lagom microservice framework
  • 25. 5 . 2 Design philosophy Distributed Asynchronous Productivity
  • 26. 5 . 3 Concepts Microservices Polyglot Design Driven APIs Immutability Event Sourcing and CQRS
  • 27. 5 . 4 Opiniated ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> stream(); @Override default Descriptor descriptor() { return named("stream").withCalls(namedCall("stream", this::stream)) .withAutoAcl(true); }
  • 28. 5 . 5 Core technologies Akka Akka Streams Akka Persistence Akka Cluster Play ConductR
  • 29. 5 . 6 Lagom persistence Cassandra PersistentEntity Requires Command, Eventand State Single instance kept in memory
  • 30. 5 . 7 Command - Event - State
  • 31.
  • 32. 5 . 8 5 . 9 Get me all inspections with remarks for a given ship Query example
  • 33. 5 . 10 Lagom JDBC support Available in 1.2 release Slick Storing and reading entities
  • 35. 6 . 27 . 1 Wrapping Up
  • 36. 7 . 2 Lessons learned Conventions make setup easy Framework on top of many layers
  • 37. ... [INFO] Service locator is running at http://localhost:8000 [INFO] Service gateway is running at http://localhost:9000 ... [INFO] (Service started, press enter to stop and go back to the console...) [error] c.l.l.i.s.ServiceRegistrationModule$RegisterWithServiceRegistry - Service name=[hello] couldn't register itself to the service locator. com.lightbend.lagom.javadsl.api.transport.TransportException: <head> ... [error] a.c.s.PersistentShardCoordinator - Persistence failure when replaying events for persistenceId [/sharding/HelloEntityCoordinator]. Last known sequence number [0] com.lightbend.lagom.javadsl.api.transport.PolicyViolation: <head> ...
  • 38. 7 . 3 7 . 4 Links Martin Fowler - CQRS Microsoft - CQRS Journey Lagom Framework Miel Donkers - Lagom CQRS Demo
  • 39. 7 . 5 Thank You!
  • 40. 7 . 6 We're hiring