SlideShare uma empresa Scribd logo
1 de 31
CQRS
&
Event sourcing
Event sourcing
Event sourcing
About me
• Lifetime hacker
• Explorer of technologies
• Polyglot programmer
• @sorenmat
• https://github.com/sorenmat
CQRS + ES
• What is CQRS
• What is Event sourcing
• Demo
Typical N-TIER architecture
pros
• Well known
• Accepted by
management
• Lots of resources
• Lots of frameworks
Typical N-TIER architecture
cons
• Complex
• Business logic bleeds through
layers
• Validation everywhere
• No provable audit trail
• No concept of change
• Caching
• Hard to scale
No concept of change -> class
change customer state means
what ever hibernate says
No concept of change -> class
change customer state means
what ever hibernate says
CQRS to the rescue
CQRS
W
TF
!!
CQRS to the resuce
Command
Query
Responsibility
Segregation
W
TF
!!
CQRS
Based upon Bertrand Meyer’s Command
Query Separation (CQS) principle:
“every method should either be a command that
performs an action, or a query that returns data to
the caller, but not both. In other words, asking a
question should not change the answer” (Meyer)
Why CQRS ?
• Scalability
• Reduced complexity
• Flexibility
• Focus on the business
Making commands, gives focus on
the business
Making commands, gives focus on
the business
CQRS in the making
• Let’s focus on the language -
AddItemToBasket vs UpdateBasket
• Task based UI
• We need to separate reads from writes
• Lets split our architecture
CQRS Structure
Commands
• Commands ask the
system to do changes
• Commands can fail
• State intent
• Can be asynchronous
Stale data
• Async - ooohh nooes
• Eventual consistency
• How stale must stale data be ?
• How stale is your data ?
• Design for it
Read Models
• Build for the “UI”
• Optimized for the
use case
• Comes in all shape
and forms
Event sourcing
Don’t save the result, save the steps !
Event sourcing
•Analysis and access to historic data
•Provable Audit log
•Flexibility to create new views or queries
(CQRS)
•Replaying events for debugging
•Enables Memory Image
Aggregates
•A boundary for transactional consistency
•Only one aggregate can be modified in a single
transaction
•A cloud of related objects, both entities and
value objects
•Only the root can be referenced from outside the
aggregate
Aggregates
•Must ensure that its state never ever violates its
business invariants
•Between the boundaries, there can only be
eventual consistency
Aggregate example
• Aggregate are the “base” of the model
• Order is the aggregate root
• Order has an addLineItem method
Event stream
•Every state-modifying operation on an
aggregate results in an event
•The actual state change is achieved by applying
the event to the aggregate
OrderCreatedOrderCreated OrderLineItemAddedOrderLineItemAdded OrderLineItemRemovedOrderLineItemRemoved OrderLineItemAddedOrderLineItemAdded
Events
• Represents the state of the aggregate
• Passed tense, can’t be undone
• Events never changes
Event sourcing
• Conflict merging
• Easy integration
• Expose events through feed
• Very testable
Event store
• Stores all events
• Append only
• Single source of truth
Event store
• Simple in design
• Few operations
• append
• getAllEvents
• getEventsForAggregate
Event Store
• Performance can be gained through
snapshots
• Serialize the aggregate with an eventId
Summary
Pros and Cons
• Great performance
• Very scalable
• Auditing
• Easy to integrate
• Testable
• Tech free
• Not well known
• Different mindset
DEMO
Our model

Mais conteúdo relacionado

Mais procurados

Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...Tom Kerkhove
 
Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions Icinga
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAidan Casey
 
Go, Swarm and DevOps vs The Mighty Monolith
Go, Swarm and DevOps vs The Mighty MonolithGo, Swarm and DevOps vs The Mighty Monolith
Go, Swarm and DevOps vs The Mighty MonolithIgor Karpovich
 
Microservices Testing
Microservices TestingMicroservices Testing
Microservices TestingvodQA
 
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...Tom Kerkhove
 
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)VMware Tanzu
 
Azure Event Grid: Glue for the Internet
Azure Event Grid: Glue for the InternetAzure Event Grid: Glue for the Internet
Azure Event Grid: Glue for the InternetJeremy Likness
 
Getting started with Azure Cognitive services
Getting started with Azure Cognitive servicesGetting started with Azure Cognitive services
Getting started with Azure Cognitive servicesRick van den Bosch
 
REST API Overview with Nutanix
REST API Overview with Nutanix REST API Overview with Nutanix
REST API Overview with Nutanix NEXTtour
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angularGil Fink
 
Expose BizTalk to the world (ACSUG)
Expose BizTalk to the world (ACSUG)Expose BizTalk to the world (ACSUG)
Expose BizTalk to the world (ACSUG)Wagner Silveira
 
Control and monitor_microservices_with_microprofile
Control and monitor_microservices_with_microprofileControl and monitor_microservices_with_microprofile
Control and monitor_microservices_with_microprofileRudy De Busscher
 
Transactions in micro-services (fall 2019)
Transactions in micro-services (fall 2019)Transactions in micro-services (fall 2019)
Transactions in micro-services (fall 2019)Rudy De Busscher
 
Stateful stream processing of iIoT events with C# and containers
Stateful stream processing of iIoT events with C# and containersStateful stream processing of iIoT events with C# and containers
Stateful stream processing of iIoT events with C# and containersMarco Parenzan
 
Automate your development environment with Jira and Saltstack
Automate your development environment with Jira and SaltstackAutomate your development environment with Jira and Saltstack
Automate your development environment with Jira and SaltstackNetworkedAssets
 
Monoliths vs microservices
Monoliths vs microservicesMonoliths vs microservices
Monoliths vs microservicesahmadezzeir
 

Mais procurados (19)

Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
 
Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Go, Swarm and DevOps vs The Mighty Monolith
Go, Swarm and DevOps vs The Mighty MonolithGo, Swarm and DevOps vs The Mighty Monolith
Go, Swarm and DevOps vs The Mighty Monolith
 
Microservices Testing
Microservices TestingMicroservices Testing
Microservices Testing
 
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...
Intelligent Cloud Conference 2018 - Next Generation of Data Integration with ...
 
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)
Migrating .NET and .NET Core to Pivotal Cloud Foundry (1/2)
 
Azure Event Grid: Glue for the Internet
Azure Event Grid: Glue for the InternetAzure Event Grid: Glue for the Internet
Azure Event Grid: Glue for the Internet
 
Getting started with Azure Cognitive services
Getting started with Azure Cognitive servicesGetting started with Azure Cognitive services
Getting started with Azure Cognitive services
 
REST API Overview with Nutanix
REST API Overview with Nutanix REST API Overview with Nutanix
REST API Overview with Nutanix
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
 
Expose BizTalk to the world (ACSUG)
Expose BizTalk to the world (ACSUG)Expose BizTalk to the world (ACSUG)
Expose BizTalk to the world (ACSUG)
 
Tech Talks Microservices
Tech Talks MicroservicesTech Talks Microservices
Tech Talks Microservices
 
Control and monitor_microservices_with_microprofile
Control and monitor_microservices_with_microprofileControl and monitor_microservices_with_microprofile
Control and monitor_microservices_with_microprofile
 
Transactions in micro-services (fall 2019)
Transactions in micro-services (fall 2019)Transactions in micro-services (fall 2019)
Transactions in micro-services (fall 2019)
 
Reporting
ReportingReporting
Reporting
 
Stateful stream processing of iIoT events with C# and containers
Stateful stream processing of iIoT events with C# and containersStateful stream processing of iIoT events with C# and containers
Stateful stream processing of iIoT events with C# and containers
 
Automate your development environment with Jira and Saltstack
Automate your development environment with Jira and SaltstackAutomate your development environment with Jira and Saltstack
Automate your development environment with Jira and Saltstack
 
Monoliths vs microservices
Monoliths vs microservicesMonoliths vs microservices
Monoliths vs microservices
 

Semelhante a Cqrs+es

Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRSMatthew Hawkins
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0Vinod Wilson
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event SourcingMike Bild
 
Art of Cloud Workload Translation
Art of Cloud Workload TranslationArt of Cloud Workload Translation
Art of Cloud Workload TranslationPaul Cooper
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationAndrew Siemer
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?Dmitry Buzdin
 
Manage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and moreManage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and moreMarco Parenzan
 
Observability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyObservability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyTimetrix
 
Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developerswojtek_s
 
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...Lucas Jellema
 
Cloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsCloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsTaswar Bhatti
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application DesignGlobalLogic Ukraine
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCAndy Butland
 
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...GECon_Org Team
 
Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...Ryan Hodgin
 
Observability - The good, the bad and the ugly Xp Days 2019 Kiev Ukraine
Observability -  The good, the bad and the ugly Xp Days 2019 Kiev Ukraine Observability -  The good, the bad and the ugly Xp Days 2019 Kiev Ukraine
Observability - The good, the bad and the ugly Xp Days 2019 Kiev Ukraine Aleksandr Tavgen
 
Closer Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesCloser Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesTodd Kaplinger
 
Building an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureBuilding an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureSrihari Sriraman
 
8 cloud design patterns you ought to know - Update Conference 2018
8 cloud design patterns you ought to know - Update Conference 20188 cloud design patterns you ought to know - Update Conference 2018
8 cloud design patterns you ought to know - Update Conference 2018Taswar Bhatti
 
PAC 2019 virtual Alexander Podelko
PAC 2019 virtual Alexander Podelko PAC 2019 virtual Alexander Podelko
PAC 2019 virtual Alexander Podelko Neotys
 

Semelhante a Cqrs+es (20)

Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRS
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Art of Cloud Workload Translation
Art of Cloud Workload TranslationArt of Cloud Workload Translation
Art of Cloud Workload Translation
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregation
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
Manage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and moreManage your devices with Azure IoT...and more
Manage your devices with Azure IoT...and more
 
Observability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyObservability – the good, the bad, and the ugly
Observability – the good, the bad, and the ugly
 
Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developers
 
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...
A Cloud- and Container-Based Approach to Microservices-Powered Workflows (Cod...
 
Cloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong CodeaholicsCloud Design Patterns - Hong Kong Codeaholics
Cloud Design Patterns - Hong Kong Codeaholics
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVC
 
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
 
Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...
 
Observability - The good, the bad and the ugly Xp Days 2019 Kiev Ukraine
Observability -  The good, the bad and the ugly Xp Days 2019 Kiev Ukraine Observability -  The good, the bad and the ugly Xp Days 2019 Kiev Ukraine
Observability - The good, the bad and the ugly Xp Days 2019 Kiev Ukraine
 
Closer Look at Cloud Centric Architectures
Closer Look at Cloud Centric ArchitecturesCloser Look at Cloud Centric Architectures
Closer Look at Cloud Centric Architectures
 
Building an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureBuilding an Experimentation Platform in Clojure
Building an Experimentation Platform in Clojure
 
8 cloud design patterns you ought to know - Update Conference 2018
8 cloud design patterns you ought to know - Update Conference 20188 cloud design patterns you ought to know - Update Conference 2018
8 cloud design patterns you ought to know - Update Conference 2018
 
PAC 2019 virtual Alexander Podelko
PAC 2019 virtual Alexander Podelko PAC 2019 virtual Alexander Podelko
PAC 2019 virtual Alexander Podelko
 

Último

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Cqrs+es

  • 2. About me • Lifetime hacker • Explorer of technologies • Polyglot programmer • @sorenmat • https://github.com/sorenmat
  • 3. CQRS + ES • What is CQRS • What is Event sourcing • Demo
  • 4. Typical N-TIER architecture pros • Well known • Accepted by management • Lots of resources • Lots of frameworks
  • 5. Typical N-TIER architecture cons • Complex • Business logic bleeds through layers • Validation everywhere • No provable audit trail • No concept of change • Caching • Hard to scale No concept of change -> class change customer state means what ever hibernate says No concept of change -> class change customer state means what ever hibernate says
  • 6.
  • 7. CQRS to the rescue CQRS W TF !!
  • 8. CQRS to the resuce Command Query Responsibility Segregation W TF !!
  • 9. CQRS Based upon Bertrand Meyer’s Command Query Separation (CQS) principle: “every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer” (Meyer)
  • 10. Why CQRS ? • Scalability • Reduced complexity • Flexibility • Focus on the business Making commands, gives focus on the business Making commands, gives focus on the business
  • 11. CQRS in the making • Let’s focus on the language - AddItemToBasket vs UpdateBasket • Task based UI • We need to separate reads from writes • Lets split our architecture
  • 13. Commands • Commands ask the system to do changes • Commands can fail • State intent • Can be asynchronous
  • 14. Stale data • Async - ooohh nooes • Eventual consistency • How stale must stale data be ? • How stale is your data ? • Design for it
  • 15. Read Models • Build for the “UI” • Optimized for the use case • Comes in all shape and forms
  • 17. Don’t save the result, save the steps !
  • 18. Event sourcing •Analysis and access to historic data •Provable Audit log •Flexibility to create new views or queries (CQRS) •Replaying events for debugging •Enables Memory Image
  • 19. Aggregates •A boundary for transactional consistency •Only one aggregate can be modified in a single transaction •A cloud of related objects, both entities and value objects •Only the root can be referenced from outside the aggregate
  • 20. Aggregates •Must ensure that its state never ever violates its business invariants •Between the boundaries, there can only be eventual consistency
  • 21. Aggregate example • Aggregate are the “base” of the model • Order is the aggregate root • Order has an addLineItem method
  • 22. Event stream •Every state-modifying operation on an aggregate results in an event •The actual state change is achieved by applying the event to the aggregate OrderCreatedOrderCreated OrderLineItemAddedOrderLineItemAdded OrderLineItemRemovedOrderLineItemRemoved OrderLineItemAddedOrderLineItemAdded
  • 23. Events • Represents the state of the aggregate • Passed tense, can’t be undone • Events never changes
  • 24. Event sourcing • Conflict merging • Easy integration • Expose events through feed • Very testable
  • 25. Event store • Stores all events • Append only • Single source of truth
  • 26. Event store • Simple in design • Few operations • append • getAllEvents • getEventsForAggregate
  • 27. Event Store • Performance can be gained through snapshots • Serialize the aggregate with an eventId
  • 29. Pros and Cons • Great performance • Very scalable • Auditing • Easy to integrate • Testable • Tech free • Not well known • Different mindset
  • 30. DEMO