SlideShare a Scribd company logo
1 of 28
Yuriy Taras
 Conventional architecture and its problems
 CQRS introduction
 Bonus – Event Sourcing
 Collaborations – when users are working on same set of data
 Staleness – when data may expire between read and write
Data is stale anyway. Why don’t admit it?
We can create read-optimized database to show data.
                                                 Remember OLAP and OLTP?
SELECT
title, short_text, publish_date, publisher_name, comme
nt_count FROM posts_list
Good scalability, good performance
You can use direct mapping from tables to UI
1.   Manager loads client info
2.   He’s editing data
     a)   Address is changed
     b)   Status is changed to ‘preferred’
3.   In background status is changed to ‘delinquent’
4.   Manager submits data
What would you do?
                                                       Example by Udi Dahan
Conventional way – here’s updated copy of your data, save it to database
CQRS (in fact, DDD) way – do this with your entity
 Commands are verbs – RenameUser, PublishPost
 Most of them will be idempotent – no more double submit problem
 Include version of your data – will help to resolve conflicts
 Commands are asynchronous – remember about DDD’s CQS concept?
 Do command validation before sending it – if you can’t do it without making command
 synchronous, it’s no longer a validation and we’ll talk later about it
public final class ChangeStatus implements Serializable {
// private final fields skipped
 public ChangeStatus(Status status, EntityKey userId, long
version, String description) {
    assertNotNull(status);
    if (status == Status.REQUIRES_ACTION) {
    assertNotNull(description);
    }
    // and so on
}
}
Usually it’s Domain Model – commands matches perfectly with DDD’s entities and
services.
Still you can use Transaction Script or Table Module patterns – CQRS doesn’t care.
Stale data – most of the time you’ll be able to merge changes in different branches without
conflicts.
                                                  do you see DCVS terminology here?
Example:
CustomerStatus(delinquent) + ChangeCustomerAddress = merge automatically
CustomerStatus(delinquent) + CustomerStatus(preferred) = depends on a
business logic, but probably make it delinquent and notify manager
What if billing command would be late?
CustomerStatus(preferred) + CustomerStatus(delinquent) = make it delinquent
and notify manager
 Database deadlock
 Some component down
 Kernel panic somewhere
 Bug in our software
 Other infrastructure issues
Retry!
Command processor should emit (publish) events.
Commands are DoThis. Events are ThisDone.
Read database is the most obvious subscriber:
UPDATE post_lists SET comments_count = comments_count
+ 1 WHERE post_id = #{post_id}
INSERT INTO comments_list SET …
                            Do you still remember our OLTP/OLAP analogy?
 Send email notification
 Write to file
 Notify other system via Web service or ESB
 Push notification to Web-client with Web sockets
 Ring the alarm
Pros
   Better scalability
   Taking staleness into account
   Works better in collaboration scenarios
Cons
   Harder to understand and implement
   Not widely known/adopted
   Requires more setup that conventional architecture
   In simple cases is overcomplicated
 Complex business domain
 Users that collaborate on common data
 Scalability and performance
 Large or distributed team
Conventional way to store domain objects – database tables.
Post(id: 5, title: ‘CQRS+ES’, content: ‘Today I want
to…’)
Other way be storing it as a series of events:
1. PostCreated(id: 1)
2. PostTitled(‘CQRS+ES’)
3. PostContentSet(‘Will add content later’)
4. PostContentSet(‘I want to…’)
5. PostPublished(Fri, 13)
Pros
   Audit for free
   Event centric
   Better conflict merging
   Simpler testing
Cons
   Even more infrastructure to set up (snapshots, cleanups, etc)
   Not very known/popular
   Higher entrance threshold
 CQRS Jorney http://msdn.microsoft.com/en-us/library/jj554200.aspx
 CQRS Blog http://cqrs.wordpress.com/
 Clarified CQRS http://www.udidahan.com/2009/12/09/clarified-cqrs/
 Fowler’s articles
   http://martinfowler.com/bliki/CQRS.html
   http://martinfowler.com/eaaDev/EventSourcing.html

 Other links http://www.mindmeister.com/181195534/cqrs-ddd-links

More Related Content

What's hot

Lect 08 materialized view
Lect 08 materialized viewLect 08 materialized view
Lect 08 materialized viewBilal khan
 
Parallel processing in data warehousing and big data
Parallel processing in data warehousing and big dataParallel processing in data warehousing and big data
Parallel processing in data warehousing and big dataAbhishek Sharma
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management systemsmumbahelp
 
DATABASE INTRODUCTION
DATABASE INTRODUCTIONDATABASE INTRODUCTION
DATABASE INTRODUCTIONghazi103
 
Orleans Cloud Computing
Orleans Cloud Computing  Orleans Cloud Computing
Orleans Cloud Computing Huzaifa zafar
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management systemsmumbahelp
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentationkaashiv1
 
New Features Sql 2008
New Features Sql 2008New Features Sql 2008
New Features Sql 2008tomerl
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management systemsmumbahelp
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management systemsmumbahelp
 
PATTERNS08 - Strong Typing and Data Validation in .NET
PATTERNS08 - Strong Typing and Data Validation in .NETPATTERNS08 - Strong Typing and Data Validation in .NET
PATTERNS08 - Strong Typing and Data Validation in .NETMichael Heron
 
Distributed database
Distributed databaseDistributed database
Distributed databasesanjay joshi
 

What's hot (16)

Lect 08 materialized view
Lect 08 materialized viewLect 08 materialized view
Lect 08 materialized view
 
Parallel processing in data warehousing and big data
Parallel processing in data warehousing and big dataParallel processing in data warehousing and big data
Parallel processing in data warehousing and big data
 
Discover Database
Discover DatabaseDiscover Database
Discover Database
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management system
 
DATABASE INTRODUCTION
DATABASE INTRODUCTIONDATABASE INTRODUCTION
DATABASE INTRODUCTION
 
Orleans Cloud Computing
Orleans Cloud Computing  Orleans Cloud Computing
Orleans Cloud Computing
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management system
 
Ch12
Ch12Ch12
Ch12
 
Chapter 4 u
Chapter 4 uChapter 4 u
Chapter 4 u
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentation
 
Distributed D B
Distributed  D BDistributed  D B
Distributed D B
 
New Features Sql 2008
New Features Sql 2008New Features Sql 2008
New Features Sql 2008
 
Mca3020 advanced database management system
Mca3020  advanced database management systemMca3020  advanced database management system
Mca3020 advanced database management system
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management system
 
PATTERNS08 - Strong Typing and Data Validation in .NET
PATTERNS08 - Strong Typing and Data Validation in .NETPATTERNS08 - Strong Typing and Data Validation in .NET
PATTERNS08 - Strong Typing and Data Validation in .NET
 
Distributed database
Distributed databaseDistributed database
Distributed database
 

Viewers also liked

Domain driven design
Domain driven designDomain driven design
Domain driven designYura Taras
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiekBart Van Belle
 
Amigos de verdad
Amigos de verdadAmigos de verdad
Amigos de verdaderickadomi
 
Phenomenal Oct, 29, 2009
Phenomenal Oct, 29, 2009Phenomenal Oct, 29, 2009
Phenomenal Oct, 29, 2009etalcomendras
 
Login Seminars Blackboard Directions 2009
Login Seminars Blackboard Directions 2009Login Seminars Blackboard Directions 2009
Login Seminars Blackboard Directions 2009Ohio LETC
 
Apture Publisher Overview
Apture Publisher OverviewApture Publisher Overview
Apture Publisher OverviewApture
 
Biopython at BOSC 2010
Biopython at BOSC 2010Biopython at BOSC 2010
Biopython at BOSC 2010Brad Chapman
 
Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009etalcomendras
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partiesfa_angeiologie
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugginglienhard
 
Itf ipp ch10_2012_final
Itf ipp ch10_2012_finalItf ipp ch10_2012_final
Itf ipp ch10_2012_finaldphil002
 

Viewers also liked (20)

Domain driven design
Domain driven designDomain driven design
Domain driven design
 
201506 CSE340 Lecture 14
201506 CSE340 Lecture 14201506 CSE340 Lecture 14
201506 CSE340 Lecture 14
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiek
 
Amigos de verdad
Amigos de verdadAmigos de verdad
Amigos de verdad
 
Huizenprijzen in amsterdam
Huizenprijzen in amsterdamHuizenprijzen in amsterdam
Huizenprijzen in amsterdam
 
Mpv2010
Mpv2010Mpv2010
Mpv2010
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Thehub euromed
Thehub   euromedThehub   euromed
Thehub euromed
 
Phenomenal Oct, 29, 2009
Phenomenal Oct, 29, 2009Phenomenal Oct, 29, 2009
Phenomenal Oct, 29, 2009
 
201506 CSE340 Lecture 16
201506 CSE340 Lecture 16201506 CSE340 Lecture 16
201506 CSE340 Lecture 16
 
Week9
Week9Week9
Week9
 
Login Seminars Blackboard Directions 2009
Login Seminars Blackboard Directions 2009Login Seminars Blackboard Directions 2009
Login Seminars Blackboard Directions 2009
 
Apture Publisher Overview
Apture Publisher OverviewApture Publisher Overview
Apture Publisher Overview
 
Biopython at BOSC 2010
Biopython at BOSC 2010Biopython at BOSC 2010
Biopython at BOSC 2010
 
Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partie
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugging
 
Itf ipp ch10_2012_final
Itf ipp ch10_2012_finalItf ipp ch10_2012_final
Itf ipp ch10_2012_final
 
201506 CSE340 Lecture 13
201506 CSE340 Lecture 13201506 CSE340 Lecture 13
201506 CSE340 Lecture 13
 
Windowsxp
WindowsxpWindowsxp
Windowsxp
 

Similar to CQRS introduction

Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaLucas Jellema
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0Joe Stein
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRSDavid Hoerster
 
Software architecture case study - why and why not sql server replication
Software architecture   case study - why and why not sql server replicationSoftware architecture   case study - why and why not sql server replication
Software architecture case study - why and why not sql server replicationShahzad
 
Air Line Management System | DBMS project
Air Line Management System | DBMS projectAir Line Management System | DBMS project
Air Line Management System | DBMS projectAniketHandore
 
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling FailuresArchitectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling FailuresGleicon Moraes
 
Questions On The Code And Core Module
Questions On The Code And Core ModuleQuestions On The Code And Core Module
Questions On The Code And Core ModuleKatie Gulley
 
Using Cassandra with your Web Application
Using Cassandra with your Web ApplicationUsing Cassandra with your Web Application
Using Cassandra with your Web Applicationsupertom
 
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...Nati Shalom
 
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache CassandraMovile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache CassandraDataStax Academy
 
Cassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of SeasonsCassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of SeasonsEiti Kimura
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAConcentrated Technology
 
Data base testing
Data base testingData base testing
Data base testingBugRaptors
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallssam2sung2
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availabilityPeter Gfader
 

Similar to CQRS introduction (20)

Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas Jellema
 
Cassandra data modelling best practices
Cassandra data modelling best practicesCassandra data modelling best practices
Cassandra data modelling best practices
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
 
Software architecture case study - why and why not sql server replication
Software architecture   case study - why and why not sql server replicationSoftware architecture   case study - why and why not sql server replication
Software architecture case study - why and why not sql server replication
 
Air Line Management System | DBMS project
Air Line Management System | DBMS projectAir Line Management System | DBMS project
Air Line Management System | DBMS project
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling FailuresArchitectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
 
Questions On The Code And Core Module
Questions On The Code And Core ModuleQuestions On The Code And Core Module
Questions On The Code And Core Module
 
AWS RDS Migration Tool
AWS RDS Migration Tool AWS RDS Migration Tool
AWS RDS Migration Tool
 
Using Cassandra with your Web Application
Using Cassandra with your Web ApplicationUsing Cassandra with your Web Application
Using Cassandra with your Web Application
 
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...
Designing a Scalable Twitter - Patterns for Designing Scalable Real-Time Web ...
 
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache CassandraMovile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
 
Cassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of SeasonsCassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of Seasons
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
 
Supporting SQLserver
Supporting SQLserverSupporting SQLserver
Supporting SQLserver
 
No sql
No sqlNo sql
No sql
 
Data base testing
Data base testingData base testing
Data base testing
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 

Recently uploaded

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

CQRS introduction

  • 2.  Conventional architecture and its problems  CQRS introduction  Bonus – Event Sourcing
  • 3.
  • 4.
  • 5.  Collaborations – when users are working on same set of data  Staleness – when data may expire between read and write
  • 6.
  • 7.
  • 8.
  • 9. Data is stale anyway. Why don’t admit it? We can create read-optimized database to show data. Remember OLAP and OLTP? SELECT title, short_text, publish_date, publisher_name, comme nt_count FROM posts_list Good scalability, good performance You can use direct mapping from tables to UI
  • 10. 1. Manager loads client info 2. He’s editing data a) Address is changed b) Status is changed to ‘preferred’ 3. In background status is changed to ‘delinquent’ 4. Manager submits data What would you do? Example by Udi Dahan
  • 11. Conventional way – here’s updated copy of your data, save it to database CQRS (in fact, DDD) way – do this with your entity
  • 12.  Commands are verbs – RenameUser, PublishPost  Most of them will be idempotent – no more double submit problem  Include version of your data – will help to resolve conflicts  Commands are asynchronous – remember about DDD’s CQS concept?  Do command validation before sending it – if you can’t do it without making command synchronous, it’s no longer a validation and we’ll talk later about it
  • 13. public final class ChangeStatus implements Serializable { // private final fields skipped public ChangeStatus(Status status, EntityKey userId, long version, String description) { assertNotNull(status); if (status == Status.REQUIRES_ACTION) { assertNotNull(description); } // and so on } }
  • 14. Usually it’s Domain Model – commands matches perfectly with DDD’s entities and services. Still you can use Transaction Script or Table Module patterns – CQRS doesn’t care.
  • 15. Stale data – most of the time you’ll be able to merge changes in different branches without conflicts. do you see DCVS terminology here? Example: CustomerStatus(delinquent) + ChangeCustomerAddress = merge automatically CustomerStatus(delinquent) + CustomerStatus(preferred) = depends on a business logic, but probably make it delinquent and notify manager What if billing command would be late? CustomerStatus(preferred) + CustomerStatus(delinquent) = make it delinquent and notify manager
  • 16.  Database deadlock  Some component down  Kernel panic somewhere  Bug in our software  Other infrastructure issues Retry!
  • 17. Command processor should emit (publish) events. Commands are DoThis. Events are ThisDone.
  • 18. Read database is the most obvious subscriber: UPDATE post_lists SET comments_count = comments_count + 1 WHERE post_id = #{post_id} INSERT INTO comments_list SET … Do you still remember our OLTP/OLAP analogy?
  • 19.  Send email notification  Write to file  Notify other system via Web service or ESB  Push notification to Web-client with Web sockets  Ring the alarm
  • 20.
  • 21.
  • 22. Pros Better scalability Taking staleness into account Works better in collaboration scenarios Cons Harder to understand and implement Not widely known/adopted Requires more setup that conventional architecture In simple cases is overcomplicated
  • 23.  Complex business domain  Users that collaborate on common data  Scalability and performance  Large or distributed team
  • 24. Conventional way to store domain objects – database tables. Post(id: 5, title: ‘CQRS+ES’, content: ‘Today I want to…’)
  • 25. Other way be storing it as a series of events: 1. PostCreated(id: 1) 2. PostTitled(‘CQRS+ES’) 3. PostContentSet(‘Will add content later’) 4. PostContentSet(‘I want to…’) 5. PostPublished(Fri, 13)
  • 26. Pros Audit for free Event centric Better conflict merging Simpler testing Cons Even more infrastructure to set up (snapshots, cleanups, etc) Not very known/popular Higher entrance threshold
  • 27.
  • 28.  CQRS Jorney http://msdn.microsoft.com/en-us/library/jj554200.aspx  CQRS Blog http://cqrs.wordpress.com/  Clarified CQRS http://www.udidahan.com/2009/12/09/clarified-cqrs/  Fowler’s articles  http://martinfowler.com/bliki/CQRS.html  http://martinfowler.com/eaaDev/EventSourcing.html  Other links http://www.mindmeister.com/181195534/cqrs-ddd-links