CQRS innovations (English version)
Upcoming SlideShare
Loading in...5

CQRS innovations (English version)






Total Views
Views on SlideShare
Embed Views



1 Embed 36

http://heeha.wordpress.com 36



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

CQRS innovations (English version) CQRS innovations (English version) Presentation Transcript

  • CQRS - Innovative solution for problemsof modern enterprise architectures. Andrey Lomakin (lomakin.andrey@gmail.com) Artem Orobets (enisher@gmail.com)January 1, 2013 www.ExigenServices.com
  • Table of content1. Why CQRS ? a) Milestones of enterprise architecture history b) Pitfalls of CRUD c) CQRS as solution2. CQRS internals3. Axon framework as CQRS implementation 2 www.ExigenServices.com
  • Why CQRS ?I. Why CQRS ? 3 www.ExigenServices.com
  • Back to the beginningLets talk about evolution of enterprise architecture ? 4 www.ExigenServices.com
  • Evolution of presentation of documentsEpoch of paper documents 5 www.ExigenServices.com
  • Evolution of presentation of documentsEpoch 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 processingEpoch 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 componentsthat can be manipulated visually in a buildertool”. 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. Performanceoptimization and consequences.Usage of ORM tools with denormalization dilutes 14 www.ExigenServices.com
  • Problem #3. ScalabilityDuring 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 solutionIII. CQRS as solution 17 www.ExigenServices.com
  • CQRSCQRS - Command QueryResponsibility Segregation 18 www.ExigenServices.com
  • Problem # 1: Usage of JavaBeansJavaBeans 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 sideEach 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 state1. 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 stateAdvantages:  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 Correctcustomer address Conflict Customer resolver reallocated Customerreallocated 27 www.ExigenServices.com
  • Architecture of CQRS applicationsIV. 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 queryConversion 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
  • CommandsCommand – 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 frameworksV. CQRS frameworks 37 www.ExigenServices.com
  • Axon frameworkAxon framework - most popular and feature rich. 38 www.ExigenServices.com
  • Example of CQRS applicationAddress 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 JPAEvent Store File System JPA Mongo DB 49 www.ExigenServices.com
  • Event Stores – pros and cons JPA Event Store Mongo DB, File systemTransactional 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
  • Sources1. First CQRS introduction http://www.infoq.com/presentations/greg- young-unshackle-qcon082. 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