CQRS in an hour or so 1. Who is jdn? Me, aka John Nuechterlein Blog: Operations Manager – Developer.

Slides:



Advertisements
Similar presentations
Forward Data Cache Integration Pattern
Advertisements

Bellwork If you roll a die, what is the probability that you roll a 2 or an odd number? P(2 or odd) 2. Is this an example of mutually exclusive, overlapping,
Distributed Systems Architectures
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Service Oriented Architecture Reference Model
Wikispaces 101 Training Standards & Interoperability (S&I) Framework May 30, :00 - 5:00pm EDT 1.
Introduction RIMResistance is Futile, you Will be Assimilated!
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
XP New Perspectives on Microsoft Office Word 2003 Tutorial 7 1 Microsoft Office Word 2003 Tutorial 7 – Collaborating With Others and Creating Web Pages.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
Child Health Reporting System (CHRS) How to Submit VHSS Data
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Relational data integrity
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
ELH 1 ELHs - Part 2, Development Initial identification of events and assignment to functions Construction of event/entity Matrix Drawing entity life histories.
|epcc| NeSC Workshop Open Issues in Grid Scheduling Ali Anjomshoaa EPCC, University of Edinburgh Tuesday, 21 October 2003 Overview of a Grid Scheduling.
ZMQS ZMQS
© Copyright 2004 United Parcel Service of America, Inc. UPS, the UPS brandmark, and the color brown are registered trademarks of United Parcel Service.
Database Systems: Design, Implementation, and Management
Week 2 The Object-Oriented Approach to Requirements
BT Wholesale October Creating your own telephone network WHOLESALE CALLS LINE ASSOCIATED.
Systems Analysis and Design in a Changing World, 6th Edition
Information Systems Today: Managing in the Digital World
GETTING STARTED WITH WINDOWS COMMUNICATION FOUNDATION 4.5 Ed Jones & Grey Guindon.
ABC Technology Project
MySQL Access Privilege System
Megastore: Providing Scalable, Highly Available Storage for Interactive Services. Presented by: Hanan Hamdan Supervised by: Dr. Amer Badarneh 1.
1 of 27 DA1241 Archive Companies Last updated: March-2004 DA1241 Archive Companies.
1 Contract Inactivation & Replacement Fly-in Action ( Continue to Page Down/Click on each page…) Electronic Document Access (EDA)
“The Honeywell Web-based Corrective Action Solution”
CSU Extension Webpage Template Session 8 April 2010.
IS 4420 Database Fundamentals Chapter 11: Data Warehousing Leon Chen
We are learning how to read the 24 hour clock
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
Proprietary and Confidential External Job Board Posting In FOX Live on Monday – October 20,
Executional Architecture
Stereotypes & Framework in conceptual architecture Lecture
Implementation Architecture
NIMS Resource Management IS-700.A – January 2009 Visual 5.1 NIMS Resource Management Unit 5.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
School Census Summer 2010 Headlines 1 Jim Haywood Product Manager for Statutory Returns Version 1.0.
Test B, 100 Subtraction Facts
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Week 1.
11 Simple Things You Can Do Next Week to Make More Money Selling SSL Bob Angus, VeriSign.
We will resume in: 25 Minutes.
Distributed DBMS©M. T. Özsu & P. Valduriez Ch.15/1 Outline Introduction Background Distributed Database Design Database Integration Semantic Data Control.
1 Unit 1 Kinematics Chapter 1 Day
1 PART 1 ILLUSTRATION OF DOCUMENTS  Brief introduction to the documents contained in the envelope  Detailed clarification of the documents content.
Copyright 2013 – Noah Mendelsohn Compiling C Programs Noah Mendelsohn Tufts University Web:
NHibernate Object/Relational Persistence for.NET.
1 XML Web Services Practical Implementations Bob Steemson Product Architect iSOFT plc.
Rethink your architecture with CQRS Pieter Joost van de Sande Passionated software developer, Atos pjvds.
Entity Framework Code First End to End
Scalable Architecture for the Cloud. What????  Command Query Responsibility Segregation  What is it?  What kinds of apps is it for?  What are the.
© Copyright 2010 Imaginet. All rights reserved. Distributed Architecture Patterns CQRS & Event Sourcing.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Enterprise Integration Patterns CS3300 Fall 2015.
Udi Dahan – The Software Simplist Session Code: ARC 304.
So you think you know pub/sub ? Udi Dahan in
Presentation transcript:

CQRS in an hour or so 1

Who is jdn? Me, aka John Nuechterlein Blog: Operations Manager – Developer – Architect - Raging Douchebag eCom then Finance hopefully ecom again background Ph.D. in Philosophy (University of Miami at the age of 25) – HI JEREMY!!!!!!! 2

Sources Greg Young – 009/08/13/command-query-separation.aspx Udi Dahan – cqrs/ Mark Nijhof – young/ 3

CQRS CQRS = “Command Query Responsibility Segregation” Huh? A design – pattern -architecture – Framework – Principle – Something Makes stuff better Huh? 4

CQS Defined Bertrand Meyer (via Wikipedia) “Command Query Separation” – “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.”method 5

CQRS defined Meyer: Separate command methods that change state from query methods that read state. Greg Young: Separate command messages that change state from query messages that read state. Can have significant architectural implications 6

Nihjof #1 7

Nihjof #2 8

Nihjof Categories 1 – Queries 2 – Commands 3 – Internal Events 4 – External Events 9

UDI #1 10

Queries ‘Reporting’ – Misleading description (Greg’s fault), but makes some sense Simple Query Layer – Simple views or sprocs or selects from denormalized tables Simple DTOs, no mapping needed – Don’t go through the Domain Model, as it pollutes it – ViewModel per query perhaps – Why should the data come across 5 layers through 3 model transformations to populate a screen? (Udi) ‘Traditional Reporting’ – Can (almost always will) have its own Model as well (and perhaps/probably its own data source) Synchronous, no messaging needed Eventual Consistency (more later) 11

Queries No mapping code, don’t even bother getting a domain object at all, e.g.: public class ModelDetailBrickDTOMapper : IMapper { public ModelDetailBrickDTO Map(Model m) { return new ModelDetailBrickDTO(m.ID, m.Name, m.Description, m.Details, m.ShippingMessage, m.GetPrice("Current"), m.GetPrice("MSRP"), m.Sizes, m.Images, DisplayProductBrick.GetRelatedDisplayProductBricksByModel(m)) ; } 12

Queries Data store – Cache it (it’s already stale) – Why not on web-tier? – Why relational? Horizontal scalability – If you cache, add a new server to handle it 13

Commands Commands capture intent, DTOs don’t – CustomerDTO vs CustomerChangedAddressCommand Part of the ‘Ubiquitous’ Language Handler per command Can be validated outside of domain entities This is why no getters/setters on domain entities, their state is updated by processing commands according to the rules of the business This is why domain entities are never invalid, commands that would produce invalid state are rejected 14

Commands Separate Data Modification – Make preferred – Change address – Delinquent payment event example Comes in 1 ms after make preferred event What to do? – A generic DTO could do these things, of course, but after the fact, how do you know what actually happened? UI Implications – Excel-like screens don’t work – Commands require specific intent 15

Commands Commands can be queued – Split into separate queues Scale where needed Commands don’t have to be handled by the domain 16

Internal Events Triggered by commands Can be persisted – Could be RDBMS, ODBMS, Document DB, etc. – Event sourcing (big topic, punting) Can be replayed – Production support benefit Snapshots can also be created & persisted – Don’t delete original events Domain can accept command or reject it – Raise event either way 17

Internal Events Write-only – “Accountants don’t use erasers” Compensating Actions/Events – Instead of rolling back a transaction, you compensate for some failure Automatic audit log – You have all the events that happened No more ‘impedence mismatch’ – You are persisting events, not rows Data mining – Like I said, you have all the events that happened 18

External Events Publishing – Typically, message bus – Could use views or ETL to process in a ‘simpler’ architecture Data stores can subscribe Only process when a read request comes in (GY) 19

External Events Publishing external events and persisting internal events done in a transaction Eventual Consistency – Latency is almost always okay – Question is, how much? – Availability trumps correctness – Acting on incomplete data is normal Event handler per view model, perhaps 20

Why not CQRS? It’s new, it’s different, I’m stupid Multiple data stores Operational Complexity Losing ACID/Transactions is scary Lots of Commands and Events and Handlers and Lions and Tigers and Bears oh my! to Code 21

Questions? 22