SlideShare une entreprise Scribd logo
1  sur  53
CQRS - Innovative solution for problems
of modern enterprise architectures.

 Andrey Lomakin (lomakin.andrey@gmail.com)
 Artem Orobets (enisher@gmail.com)
January 1, 2013    www.ExigenServices.com
Table of content

1. Why CQRS ?
   a) Milestones of enterprise architecture history
   b) Pitfalls of CRUD
   c) CQRS as solution
2. CQRS internals
3. Axon framework as CQRS implementation




                                                      2   www.ExigenServices.com
Why CQRS ?




I. Why CQRS ?

             3   www.ExigenServices.com
Back to the beginning


Lets talk about evolution of enterprise
             architecture
                ?




                               4   www.ExigenServices.com
Evolution of presentation of documents




Epoch of paper documents
                            5   www.ExigenServices.com
Evolution of presentation of documents




Epoch of electronic storages
                            6   www.ExigenServices.com
Epoch of electronic storages




                           7   www.ExigenServices.com
Epoch of electronic storages




                           8   www.ExigenServices.com
Evolution of data processing

Epoch of business processes




                               9   www.ExigenServices.com
However…




CRUD approach is oriented on data
 manipulation, but not on business
         logic modeling .



                           10   www.ExigenServices.com
Pitfalls of CRUD




   II. Pitfalls of CRUD



                          11   www.ExigenServices.com
Problem #1. Usage of JavaBeans ….

JavaBean – “Reusable software components
that can be manipulated visually in a builder
tool”.




                                     12   www.ExigenServices.com
… results in …

1. Broken encapsulation of business
   objects.
2. Worse code readability.
3. Harder maintainability.
4. All business logic
   is placed in service
   methods.

                                 13   www.ExigenServices.com
Problem #2. Performance
optimization and consequences.



Usage of ORM tools with
 denormalization dilutes




                           14    www.ExigenServices.com
Problem #3. Scalability


During business data processing we always chose
                C in CAP theorem




                                    15   www.ExigenServices.com
Problem #4:In real life concurrent data
         modification conflicts do not exist.




 Real life business processes do not have
  concurrent data modification conflicts.
 Detection of such conflict is sign of flaw in
  implementation of business logic.
 CRUD does not take this into account.

                                          16   www.ExigenServices.com
CQRS as solution




III. CQRS as solution
                     17   www.ExigenServices.com
CQRS




CQRS - Command Query
Responsibility Segregation

                    18   www.ExigenServices.com
Problem # 1: Usage of JavaBeans



JavaBeans are still used on query side only
     but JavaBean != Domain Entity.




                                    19    www.ExigenServices.com
Problem #2. Performance optimization and
  consequences.




Data denormailzation is used
     on query side only



                                20   www.ExigenServices.com
Data on query side

Each table – reflection of presentation of data on user
                         screen.

     Database are not restricted to be SQL only.

  Possible alternatives - Apache Cassandra, HBase,
                     OrientDB ….


                                          21   www.ExigenServices.com
Problem #3. Scalability




 Data consistency is needed on business
  logic side only.
 On query side eventual consistency is
  totally acceptable.



                                  22   www.ExigenServices.com
Problem #4:In real life concurrent data
           modification conflicts do not exist.


Two approaches to present object state

1. In the form of values of variables inside object




                                            23   www.ExigenServices.com
Two approaches to present object state


                2. In form of event queue




+11.2 M $   + 5.3 M $                                  - 8.2 M $

                              Sum: 8.3 M $




                                             24   www.ExigenServices.com
Two approaches to present object state




 Each aggregate (DDD) – event container.
 There is no need to use relational
  databases.
 It is preferable to have DB with ACID
  properties.

                                    25   www.ExigenServices.com
Two approaches to present object state

Advantages:
   System monitoring support.
   Ability rollback system state till any moment in
    the past.
   Framework for data replication and conflict
    resolution.



                                         26   www.ExigenServices.com
Conflict resolution


 Correct
customer
 address

                          Conflict     Customer
                          resolver    reallocated

 Customer
reallocated




                                     27      www.ExigenServices.com
Architecture of CQRS applications




IV. Architecture of CQRS applications



                                   28   www.ExigenServices.com
CQRS – is approach only




       CQRS is approach only,
how it will be implemented, depends
                on you.


                                29   www.ExigenServices.com
Queries


  Multilayer architecture              CQRS

         DB query                     DB query


Conversion to domain model   Conversion to domain model


     Conversion to DTO           Conversion to DTO

   Transmutation of data        Transmutation of data
         to client                    to client

                                           31    www.ExigenServices.com
Commands

Command – presentation of business action, action
  which is meaningful for end user.

Advantages of usage of commands:
1. Orientation on business problems.
2. Convenient facilities for monitoring and scalability.




                                               33   www.ExigenServices.com
….advantages…..

1. Good preconditions for DDD usage.
2. Usage of complex event processing
   possibilities.
3. Simplicity of distribution of responsibilities
   between highly specialized commands.




                                      36   www.ExigenServices.com
CQRS frameworks




V. CQRS frameworks

                    37   www.ExigenServices.com
Axon framework




Axon framework - most popular and
           feature rich.

                          38   www.ExigenServices.com
Example of CQRS application




Address Book – address
 list management




                                      39   www.ExigenServices.com
Command creation and submission




                          41   www.ExigenServices.com
Command processing




                     43   www.ExigenServices.com
Business action




                  44   www.ExigenServices.com
Event processing on query side




                            45   www.ExigenServices.com
Query side




             47   www.ExigenServices.com
Simplicity of configuration




                              48   www.ExigenServices.com
Axon – repository и event store.



Repository

                                 JPA



Event Store

               File System       JPA            Mongo DB
                                           49      www.ExigenServices.com
Event Stores – pros and cons

    JPA Event Store

                            Mongo DB, File system




Transactional but slow

                             There is no ACID support
                                 better performance

                                          50   www.ExigenServices.com
Questions



            51   www.ExigenServices.com
Authors




 Artem Orobets. twitter: @Dr_EniSh ,
   enisher@gmail.com, skype: dr_enish
 Andrey Lomakin. twitter: @Andrey_Lomakin ,
  lomakin.andrey@gmail.com , skype: lomakin_andrey




                                                 52   www.ExigenServices.com
Sources

1. First CQRS introduction http://www.infoq.com/presentations/greg-
   young-unshackle-qcon08
2. CQRS architecture overview -
   http://elegantcode.com/2009/11/11/cqrs-la-greg-young/
3. Greg Young blog - http://codebetter.com/gregyoung/
4. Race conditions does not exist
   http://www.udidahan.com/2010/08/31/race-conditions-dont-exist/
5. Domain Driven Design Aggregator -
   http://domaindrivendesign.org/
6. Axon framework home page -
   http://code.google.com/p/axonframework/
7. Mark Nijhof blog http://cre8ivethought.com/blog


                                                     53    www.ExigenServices.com

Contenu connexe

Similaire à CQRS innovations (English version)

Enterprise Trends for MongoDB as a Service
Enterprise Trends for MongoDB as a ServiceEnterprise Trends for MongoDB as a Service
Enterprise Trends for MongoDB as a ServiceMongoDB
 
MicroServices-Part-1.pdf
MicroServices-Part-1.pdfMicroServices-Part-1.pdf
MicroServices-Part-1.pdfchanhluc2112
 
JavaBeer_Clean architecture_update.v2.pptx
JavaBeer_Clean architecture_update.v2.pptxJavaBeer_Clean architecture_update.v2.pptx
JavaBeer_Clean architecture_update.v2.pptxssuser78ac77
 
Solving enterprise applications performance puzzles queuing models to the r...
Solving enterprise applications performance puzzles   queuing models to the r...Solving enterprise applications performance puzzles   queuing models to the r...
Solving enterprise applications performance puzzles queuing models to the r...Leonid Grinshpan, Ph.D.
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Chris Richardson
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning IntroductionMyOnlineITCourses
 
WORKSHOP: Microservices as Containers on AWS
WORKSHOP: Microservices as Containers on AWSWORKSHOP: Microservices as Containers on AWS
WORKSHOP: Microservices as Containers on AWSCasey Lee
 
设计开发实效 Web2.0 应用程序
设计开发实效 Web2.0 应用程序设计开发实效 Web2.0 应用程序
设计开发实效 Web2.0 应用程序Shawn Zhu
 
Containers as Infrastructure for New Gen Apps
Containers as Infrastructure for New Gen AppsContainers as Infrastructure for New Gen Apps
Containers as Infrastructure for New Gen AppsKhalid Ahmed
 
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorEfficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorMark Matthews
 
Sunserver Open Solaris
Sunserver Open SolarisSunserver Open Solaris
Sunserver Open Solarispankaj009
 
Refactoring to Microservices
Refactoring to MicroservicesRefactoring to Microservices
Refactoring to MicroservicesJacinto Limjap
 
Cytoscape CI Chapter 2
Cytoscape CI Chapter 2Cytoscape CI Chapter 2
Cytoscape CI Chapter 2bdemchak
 
Stateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the CloudStateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the CloudMarkus Eisele
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaAraf Karsh Hamid
 
When Architecture Meets Data
When Architecture Meets DataWhen Architecture Meets Data
When Architecture Meets DataEoin Woods
 
2016 - 10 questions you should answer before building a new microservice
2016 - 10 questions you should answer before building a new microservice2016 - 10 questions you should answer before building a new microservice
2016 - 10 questions you should answer before building a new microservicedevopsdaysaustin
 
Introduction to enterprise applications capacity planning
Introduction to enterprise applications capacity planning Introduction to enterprise applications capacity planning
Introduction to enterprise applications capacity planning Leonid Grinshpan, Ph.D.
 
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...Amazon Web Services
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolithStay productive while slicing up the monolith
Stay productive while slicing up the monolithMarkus Eisele
 

Similaire à CQRS innovations (English version) (20)

Enterprise Trends for MongoDB as a Service
Enterprise Trends for MongoDB as a ServiceEnterprise Trends for MongoDB as a Service
Enterprise Trends for MongoDB as a Service
 
MicroServices-Part-1.pdf
MicroServices-Part-1.pdfMicroServices-Part-1.pdf
MicroServices-Part-1.pdf
 
JavaBeer_Clean architecture_update.v2.pptx
JavaBeer_Clean architecture_update.v2.pptxJavaBeer_Clean architecture_update.v2.pptx
JavaBeer_Clean architecture_update.v2.pptx
 
Solving enterprise applications performance puzzles queuing models to the r...
Solving enterprise applications performance puzzles   queuing models to the r...Solving enterprise applications performance puzzles   queuing models to the r...
Solving enterprise applications performance puzzles queuing models to the r...
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning Introduction
 
WORKSHOP: Microservices as Containers on AWS
WORKSHOP: Microservices as Containers on AWSWORKSHOP: Microservices as Containers on AWS
WORKSHOP: Microservices as Containers on AWS
 
设计开发实效 Web2.0 应用程序
设计开发实效 Web2.0 应用程序设计开发实效 Web2.0 应用程序
设计开发实效 Web2.0 应用程序
 
Containers as Infrastructure for New Gen Apps
Containers as Infrastructure for New Gen AppsContainers as Infrastructure for New Gen Apps
Containers as Infrastructure for New Gen Apps
 
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorEfficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
 
Sunserver Open Solaris
Sunserver Open SolarisSunserver Open Solaris
Sunserver Open Solaris
 
Refactoring to Microservices
Refactoring to MicroservicesRefactoring to Microservices
Refactoring to Microservices
 
Cytoscape CI Chapter 2
Cytoscape CI Chapter 2Cytoscape CI Chapter 2
Cytoscape CI Chapter 2
 
Stateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the CloudStateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the Cloud
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
 
When Architecture Meets Data
When Architecture Meets DataWhen Architecture Meets Data
When Architecture Meets Data
 
2016 - 10 questions you should answer before building a new microservice
2016 - 10 questions you should answer before building a new microservice2016 - 10 questions you should answer before building a new microservice
2016 - 10 questions you should answer before building a new microservice
 
Introduction to enterprise applications capacity planning
Introduction to enterprise applications capacity planning Introduction to enterprise applications capacity planning
Introduction to enterprise applications capacity planning
 
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
AWS Partner Webcast - Disaster Recovery: Implementing DR Across On-premises a...
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolithStay productive while slicing up the monolith
Stay productive while slicing up the monolith
 

Dernier

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

CQRS innovations (English version)

  • 1. CQRS - Innovative solution for problems of modern enterprise architectures. Andrey Lomakin (lomakin.andrey@gmail.com) Artem Orobets (enisher@gmail.com) January 1, 2013 www.ExigenServices.com
  • 2. Table of content 1. Why CQRS ? a) Milestones of enterprise architecture history b) Pitfalls of CRUD c) CQRS as solution 2. CQRS internals 3. Axon framework as CQRS implementation 2 www.ExigenServices.com
  • 3. Why CQRS ? I. Why CQRS ? 3 www.ExigenServices.com
  • 4. Back to the beginning Lets talk about evolution of enterprise architecture ? 4 www.ExigenServices.com
  • 5. Evolution of presentation of documents Epoch of paper documents 5 www.ExigenServices.com
  • 6. Evolution of presentation of documents Epoch of electronic storages 6 www.ExigenServices.com
  • 7. Epoch of electronic storages 7 www.ExigenServices.com
  • 8. Epoch of electronic storages 8 www.ExigenServices.com
  • 9. Evolution of data processing Epoch of business processes 9 www.ExigenServices.com
  • 10. However… CRUD approach is oriented on data manipulation, but not on business logic modeling . 10 www.ExigenServices.com
  • 11. Pitfalls of CRUD II. Pitfalls of CRUD 11 www.ExigenServices.com
  • 12. Problem #1. Usage of JavaBeans …. JavaBean – “Reusable software components that can be manipulated visually in a builder tool”. 12 www.ExigenServices.com
  • 13. … results in … 1. Broken encapsulation of business objects. 2. Worse code readability. 3. Harder maintainability. 4. All business logic is placed in service methods. 13 www.ExigenServices.com
  • 14. Problem #2. Performance optimization and consequences. Usage of ORM tools with denormalization dilutes 14 www.ExigenServices.com
  • 15. Problem #3. Scalability During business data processing we always chose C in CAP theorem 15 www.ExigenServices.com
  • 16. Problem #4:In real life concurrent data modification conflicts do not exist.  Real life business processes do not have concurrent data modification conflicts.  Detection of such conflict is sign of flaw in implementation of business logic.  CRUD does not take this into account. 16 www.ExigenServices.com
  • 17. CQRS as solution III. CQRS as solution 17 www.ExigenServices.com
  • 18. CQRS CQRS - Command Query Responsibility Segregation 18 www.ExigenServices.com
  • 19. Problem # 1: Usage of JavaBeans JavaBeans are still used on query side only but JavaBean != Domain Entity. 19 www.ExigenServices.com
  • 20. Problem #2. Performance optimization and consequences. Data denormailzation is used on query side only 20 www.ExigenServices.com
  • 21. Data on query side Each table – reflection of presentation of data on user screen. Database are not restricted to be SQL only. Possible alternatives - Apache Cassandra, HBase, OrientDB …. 21 www.ExigenServices.com
  • 22. Problem #3. Scalability  Data consistency is needed on business logic side only.  On query side eventual consistency is totally acceptable. 22 www.ExigenServices.com
  • 23. Problem #4:In real life concurrent data modification conflicts do not exist. Two approaches to present object state 1. In the form of values of variables inside object 23 www.ExigenServices.com
  • 24. Two approaches to present object state 2. In form of event queue +11.2 M $ + 5.3 M $ - 8.2 M $ Sum: 8.3 M $ 24 www.ExigenServices.com
  • 25. Two approaches to present object state  Each aggregate (DDD) – event container.  There is no need to use relational databases.  It is preferable to have DB with ACID properties. 25 www.ExigenServices.com
  • 26. Two approaches to present object state Advantages:  System monitoring support.  Ability rollback system state till any moment in the past.  Framework for data replication and conflict resolution. 26 www.ExigenServices.com
  • 27. Conflict resolution Correct customer address Conflict Customer resolver reallocated Customer reallocated 27 www.ExigenServices.com
  • 28. Architecture of CQRS applications IV. Architecture of CQRS applications 28 www.ExigenServices.com
  • 29. CQRS – is approach only CQRS is approach only, how it will be implemented, depends on you. 29 www.ExigenServices.com
  • 30.
  • 31. Queries Multilayer architecture CQRS DB query DB query Conversion to domain model Conversion to domain model Conversion to DTO Conversion to DTO Transmutation of data Transmutation of data to client to client 31 www.ExigenServices.com
  • 32.
  • 33. Commands Command – presentation of business action, action which is meaningful for end user. Advantages of usage of commands: 1. Orientation on business problems. 2. Convenient facilities for monitoring and scalability. 33 www.ExigenServices.com
  • 34.
  • 35.
  • 36. ….advantages….. 1. Good preconditions for DDD usage. 2. Usage of complex event processing possibilities. 3. Simplicity of distribution of responsibilities between highly specialized commands. 36 www.ExigenServices.com
  • 37. CQRS frameworks V. CQRS frameworks 37 www.ExigenServices.com
  • 38. Axon framework Axon framework - most popular and feature rich. 38 www.ExigenServices.com
  • 39. Example of CQRS application Address Book – address list management 39 www.ExigenServices.com
  • 40.
  • 41. Command creation and submission 41 www.ExigenServices.com
  • 42.
  • 43. Command processing 43 www.ExigenServices.com
  • 44. Business action 44 www.ExigenServices.com
  • 45. Event processing on query side 45 www.ExigenServices.com
  • 46.
  • 47. Query side 47 www.ExigenServices.com
  • 48. Simplicity of configuration 48 www.ExigenServices.com
  • 49. Axon – repository и event store. Repository JPA Event Store File System JPA Mongo DB 49 www.ExigenServices.com
  • 50. Event Stores – pros and cons JPA Event Store Mongo DB, File system Transactional but slow There is no ACID support better performance 50 www.ExigenServices.com
  • 51. Questions 51 www.ExigenServices.com
  • 52. Authors  Artem Orobets. twitter: @Dr_EniSh , enisher@gmail.com, skype: dr_enish  Andrey Lomakin. twitter: @Andrey_Lomakin , lomakin.andrey@gmail.com , skype: lomakin_andrey 52 www.ExigenServices.com
  • 53. Sources 1. First CQRS introduction http://www.infoq.com/presentations/greg- young-unshackle-qcon08 2. CQRS architecture overview - http://elegantcode.com/2009/11/11/cqrs-la-greg-young/ 3. Greg Young blog - http://codebetter.com/gregyoung/ 4. Race conditions does not exist http://www.udidahan.com/2010/08/31/race-conditions-dont-exist/ 5. Domain Driven Design Aggregator - http://domaindrivendesign.org/ 6. Axon framework home page - http://code.google.com/p/axonframework/ 7. Mark Nijhof blog http://cre8ivethought.com/blog 53 www.ExigenServices.com