SlideShare a Scribd company logo
(c) 2015-16, No reproduction without permission
CQRS
Vikas Hazrati
Knoldus Software
(c) 2015-16, No reproduction without permission
What
Command Query
Responsibility Segregation
(c) 2015-16, No reproduction without permission
What
Command Query
Responsibility Segregation
Not an
architecture, just
a pattern
(c) 2015-16, No reproduction without permission
Main Idea
●
A method should either change state or
return a result, not both
●
Asking a question should not change the
answer (SRP + Immutability) – No side effects
(c) 2015-16, No reproduction without permission
Main Idea
●
Commands - change the state of an object or
entire system (sometimes called as modifiers
or mutators).
●
Queries - return results and do not change
the state of an object.
(c) 2015-16, No reproduction without permission
Real world
●
Methods which return something are mostly
queries – specialized reporting needs
●
Methods which return unit are commands –
domain with all the behavior
(c) 2015-16, No reproduction without permission
Why?
●
Helps to scale read and writes independently
●
Optimise the reads and writes separately for
performance tuning
●
Split the teams for larger projects
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Query
●
Methods for getting data
●
DTO's which are passed to the presentation
layer for presentation
●
Converting domain object to data might be
complex, in CQRS we get DTOs directly from
underlying data store
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Command Side
●
Created by the client app and sent to the
domain layer
●
Messages that instruct the entity to perform
some action
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Main Drivers
●
Collaboration – Multiple actors / objects
would be modifying the same set of data
●
Staleness – The fact that once data has been
shown to the user, it might have changed by
another actor hence rendering it stale
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Queries on an additional datastore which can be slightly out of sync
with the master but
would server data in the form required by the presentation layer.
The query data can be stored in any persistence mechanism right
from being
In memory to RDBMS
(c) 2015-16, No reproduction without permission
Commands need not be processed immediately, they can be queued.
Consider the autonomous components to be actors where every
actor is responsible for
handling a group of related commands
Since the domain model now does not serve queries, do we need
relationship between
entities on the domain model?
(c) 2015-16, No reproduction without permission
Example
CustomerService
●
void MakeCustomerPreferred(CustomerId)
●
Customer GetCustomer(CustomerId)
●
CustomerSet GetCustomersWithName(Name)
●
CustomerSet GetPreferredCustomers()
●
void ChangeCustomerLocale(CustomerId, NewLocale)
●
void CreateCustomer(Customer)
●
void EditCustomerDetails(CustomerDetails)
(c) 2015-16, No reproduction without permission
Example
CustomerService
●
void MakeCustomerPreferred(CustomerId)
●
Customer GetCustomer(CustomerId)
●
CustomerSet GetCustomersWithName(Name)
●
CustomerSet GetPreferredCustomers()
●
void ChangeCustomerLocale(CustomerId, NewLocale)
●
void CreateCustomer(Customer)
●
void EditCustomerDetails(CustomerDetails)
What would you separate
out?
(c) 2015-16, No reproduction without permission
Example
CustomerWriteService
●
void MakeCustomerPreferred(CustomerId)
●
void ChangeCustomerLocale(CustomerId, NewLocale)
●
void CreateCustomer(Customer)
●
void EditCustomerDetails(CustomerDetails)
CustomerReadService
●
Customer GetCustomer(CustomerId)
●
CustomerSet GetCustomersWithName(Name)
●
CustomerSet GetPreferredCustomers()
(c) 2015-16, No reproduction without permission
Tying it up with Event Sourcing
and Akka
(c) 2015-16, No reproduction without permission
Event Sourcing
●
Event Sourcing means that all changes to application state are stored
as a sequence of events.
●
This sequence of events can be used to query the current state of an
object but also the history of an object.
●
Event sourcing allows one to create different kinds of views, even
views which one did not even think of when creating the application.
●
Because all events are stored, one can query the event store to
create these new views based on the data- even at a later date.
(c) 2015-16, No reproduction without permission
Akka Persistence
●
Event Sourcing review
●
Persistent actor receives a command which is
first validated and if successful, event(s) are
generated.
●
These events are persisted and if successfully
persisted, change the actor's state
●
When persistent actor needs to recover,
persisted events are replayed. These events
cannot fail
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Akka Persistence
●
Command path implemented using
PersistentActor
●
Query path implemented using
PersistentView
(c) 2015-16, No reproduction without permission
Example
●
Create an Auction
●
Place a did
●
Query for the current winning bid
●
Query for the bid history
(c) 2015-16, No reproduction without permission
REST Endpoints
Or
UI
Command
Handler
Ack/nack
Domain
DB
Event
CacheQuery
Handler
(c) 2015-16, No reproduction without permission
Command
BidProcessor.scala. This is a PersistentActor
(c) 2015-16, No reproduction without permission
Query
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
(c) 2015-16, No reproduction without permission
Resources
Full credits to the following and more resources
for helping us with the understanding! Thank
you!
●
http://martinfowler.com/bliki/CQRS.html
●
http://udidahan.com/2009/12/09/clarified-cqr
s/
●
http://www.cqrsinfo.com/

More Related Content

What's hot

Componentize! by Lancer Kind XP Conference 2016
Componentize! by Lancer Kind XP Conference 2016Componentize! by Lancer Kind XP Conference 2016
Componentize! by Lancer Kind XP Conference 2016
XP Conference India
 
Introduction to lambda behave
Introduction to lambda behaveIntroduction to lambda behave
Introduction to lambda behave
RichardWarburton
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
Badoo
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & AzureBuilding Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
Xp conf-tbd
Xp conf-tbdXp conf-tbd
Xp conf-tbd
XP Conference India
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
All Things Open
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
ESUG
 
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
Paulo Clavijo
 
Automation and Technical Debt
Automation and Technical DebtAutomation and Technical Debt
Automation and Technical Debt
IBM UrbanCode Products
 
Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala	Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala
Knoldus Inc.
 
Autograder presentation
Autograder presentationAutograder presentation
Autograder presentation
Chi Heng
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
Sudheer J
 
Programação reativa functional com java 8
Programação reativa functional com java 8Programação reativa functional com java 8
Programação reativa functional com java 8
Diego Pacheco
 
River Trail: A Path to Parallelism in JavaScript
River Trail: A Path to Parallelism in JavaScriptRiver Trail: A Path to Parallelism in JavaScript
River Trail: A Path to Parallelism in JavaScript
Roberto Falconi
 
Next.js with drupal, the good parts
Next.js with drupal, the good partsNext.js with drupal, the good parts
Next.js with drupal, the good parts
Taller Negócio Digitais
 
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
Cheng You Bai
 
DevOps Toolchain v1.0
DevOps Toolchain v1.0DevOps Toolchain v1.0
DevOps Toolchain v1.0
Giragadurai Vallirajan
 
Matlab Assignment Experts Research Help
Matlab Assignment Experts Research HelpMatlab Assignment Experts Research Help
Matlab Assignment Experts Research Help
Matlab Simulation
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
Jonathan Jalouzot
 
Help with Matlab Assignment Research Help
Help with Matlab Assignment Research HelpHelp with Matlab Assignment Research Help
Help with Matlab Assignment Research Help
Matlab Simulation
 

What's hot (20)

Componentize! by Lancer Kind XP Conference 2016
Componentize! by Lancer Kind XP Conference 2016Componentize! by Lancer Kind XP Conference 2016
Componentize! by Lancer Kind XP Conference 2016
 
Introduction to lambda behave
Introduction to lambda behaveIntroduction to lambda behave
Introduction to lambda behave
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & AzureBuilding Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
 
Xp conf-tbd
Xp conf-tbdXp conf-tbd
Xp conf-tbd
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
 
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
Approval Testing & Mutation Testing - Cork Software Crafters - June 2019
 
Automation and Technical Debt
Automation and Technical DebtAutomation and Technical Debt
Automation and Technical Debt
 
Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala	Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala
 
Autograder presentation
Autograder presentationAutograder presentation
Autograder presentation
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
 
Programação reativa functional com java 8
Programação reativa functional com java 8Programação reativa functional com java 8
Programação reativa functional com java 8
 
River Trail: A Path to Parallelism in JavaScript
River Trail: A Path to Parallelism in JavaScriptRiver Trail: A Path to Parallelism in JavaScript
River Trail: A Path to Parallelism in JavaScript
 
Next.js with drupal, the good parts
Next.js with drupal, the good partsNext.js with drupal, the good parts
Next.js with drupal, the good parts
 
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
The Hitchhiker's Guide to Servo Contributor [COSCUP 2020]
 
DevOps Toolchain v1.0
DevOps Toolchain v1.0DevOps Toolchain v1.0
DevOps Toolchain v1.0
 
Matlab Assignment Experts Research Help
Matlab Assignment Experts Research HelpMatlab Assignment Experts Research Help
Matlab Assignment Experts Research Help
 
Create GraphQL server with apolloJS
Create GraphQL server with apolloJSCreate GraphQL server with apolloJS
Create GraphQL server with apolloJS
 
Help with Matlab Assignment Research Help
Help with Matlab Assignment Research HelpHelp with Matlab Assignment Research Help
Help with Matlab Assignment Research Help
 

Similar to Cqrs

Fast dataarchitecture
Fast dataarchitectureFast dataarchitecture
Fast dataarchitecture
Knoldus Inc.
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodia
vijaygolani
 
Sprint 58
Sprint 58Sprint 58
Sprint 58
ManageIQ
 
ASE Semantic Partitions- A Case Study
ASE Semantic Partitions- A Case Study ASE Semantic Partitions- A Case Study
ASE Semantic Partitions- A Case Study
SAP Technology
 
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
ApacheCon 2020 - Flink SQL in 2020: Time to show off!ApacheCon 2020 - Flink SQL in 2020: Time to show off!
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
Timo Walther
 
Sprint 43 Review
Sprint 43 ReviewSprint 43 Review
Sprint 43 Review
ManageIQ
 
Sprint 61
Sprint 61Sprint 61
Sprint 61
ManageIQ
 
Sprint 55
Sprint 55Sprint 55
Sprint 55
ManageIQ
 
Pega Lead System Architecture (CPLSA) Exam | Start Your Preparation
Pega Lead System Architecture (CPLSA) Exam | Start Your PreparationPega Lead System Architecture (CPLSA) Exam | Start Your Preparation
Pega Lead System Architecture (CPLSA) Exam | Start Your Preparation
Meghna Arora
 
Sprint 40 review
Sprint 40 reviewSprint 40 review
Sprint 40 review
ManageIQ
 
Demystifying Web Vitals
Demystifying Web VitalsDemystifying Web Vitals
Demystifying Web Vitals
Samar Panda
 
Sprint 71
Sprint 71Sprint 71
Sprint 71
ManageIQ
 
Continuous Performance Testing
Continuous Performance TestingContinuous Performance Testing
Continuous Performance Testing
Grid Dynamics
 
Turning the web stack upside down rethinking how data flows through systems
Turning the web stack upside down  rethinking how data flows through systemsTurning the web stack upside down  rethinking how data flows through systems
Turning the web stack upside down rethinking how data flows through systems
Paolo Negri
 
L13 Presentation Layer Design
L13 Presentation Layer DesignL13 Presentation Layer Design
L13 Presentation Layer Design
Ólafur Andri Ragnarsson
 
Sprint 59
Sprint 59Sprint 59
Sprint 59
ManageIQ
 
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
Quantyca - Data at Core
 
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
Taro L. Saito
 
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
Pavel Pratyush
 
Maximizing Database Tuning in SAP SQL Anywhere
Maximizing Database Tuning in SAP SQL AnywhereMaximizing Database Tuning in SAP SQL Anywhere
Maximizing Database Tuning in SAP SQL Anywhere
SAP Technology
 

Similar to Cqrs (20)

Fast dataarchitecture
Fast dataarchitectureFast dataarchitecture
Fast dataarchitecture
 
Graphql Overview By Chirag Dodia
Graphql Overview By Chirag DodiaGraphql Overview By Chirag Dodia
Graphql Overview By Chirag Dodia
 
Sprint 58
Sprint 58Sprint 58
Sprint 58
 
ASE Semantic Partitions- A Case Study
ASE Semantic Partitions- A Case Study ASE Semantic Partitions- A Case Study
ASE Semantic Partitions- A Case Study
 
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
ApacheCon 2020 - Flink SQL in 2020: Time to show off!ApacheCon 2020 - Flink SQL in 2020: Time to show off!
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
 
Sprint 43 Review
Sprint 43 ReviewSprint 43 Review
Sprint 43 Review
 
Sprint 61
Sprint 61Sprint 61
Sprint 61
 
Sprint 55
Sprint 55Sprint 55
Sprint 55
 
Pega Lead System Architecture (CPLSA) Exam | Start Your Preparation
Pega Lead System Architecture (CPLSA) Exam | Start Your PreparationPega Lead System Architecture (CPLSA) Exam | Start Your Preparation
Pega Lead System Architecture (CPLSA) Exam | Start Your Preparation
 
Sprint 40 review
Sprint 40 reviewSprint 40 review
Sprint 40 review
 
Demystifying Web Vitals
Demystifying Web VitalsDemystifying Web Vitals
Demystifying Web Vitals
 
Sprint 71
Sprint 71Sprint 71
Sprint 71
 
Continuous Performance Testing
Continuous Performance TestingContinuous Performance Testing
Continuous Performance Testing
 
Turning the web stack upside down rethinking how data flows through systems
Turning the web stack upside down  rethinking how data flows through systemsTurning the web stack upside down  rethinking how data flows through systems
Turning the web stack upside down rethinking how data flows through systems
 
L13 Presentation Layer Design
L13 Presentation Layer DesignL13 Presentation Layer Design
L13 Presentation Layer Design
 
Sprint 59
Sprint 59Sprint 59
Sprint 59
 
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
Create a One Click Migration (OCM) process to Automate Repeatable Infrastruct...
 
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
Journey of Migrating 1 Million Presto Queries - Presto Webinar 2020
 
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
Migration of a high-traffic E-commerce website from Legacy Monolith to Micros...
 
Maximizing Database Tuning in SAP SQL Anywhere
Maximizing Database Tuning in SAP SQL AnywhereMaximizing Database Tuning in SAP SQL Anywhere
Maximizing Database Tuning in SAP SQL Anywhere
 

More from Knoldus Inc.

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
Knoldus Inc.
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
Knoldus Inc.
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
Knoldus Inc.
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
Knoldus Inc.
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
Knoldus Inc.
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
Knoldus Inc.
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
Knoldus Inc.
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
Knoldus Inc.
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
Knoldus Inc.
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
Knoldus Inc.
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
Knoldus Inc.
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
Knoldus Inc.
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
Knoldus Inc.
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
Knoldus Inc.
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
Knoldus Inc.
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
Knoldus Inc.
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Knoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
Knoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
Knoldus Inc.
 

More from Knoldus Inc. (20)

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 

Cqrs

  • 1. (c) 2015-16, No reproduction without permission CQRS Vikas Hazrati Knoldus Software
  • 2. (c) 2015-16, No reproduction without permission What Command Query Responsibility Segregation
  • 3. (c) 2015-16, No reproduction without permission What Command Query Responsibility Segregation Not an architecture, just a pattern
  • 4. (c) 2015-16, No reproduction without permission Main Idea ● A method should either change state or return a result, not both ● Asking a question should not change the answer (SRP + Immutability) – No side effects
  • 5. (c) 2015-16, No reproduction without permission Main Idea ● Commands - change the state of an object or entire system (sometimes called as modifiers or mutators). ● Queries - return results and do not change the state of an object.
  • 6. (c) 2015-16, No reproduction without permission Real world ● Methods which return something are mostly queries – specialized reporting needs ● Methods which return unit are commands – domain with all the behavior
  • 7. (c) 2015-16, No reproduction without permission Why? ● Helps to scale read and writes independently ● Optimise the reads and writes separately for performance tuning ● Split the teams for larger projects
  • 8. (c) 2015-16, No reproduction without permission
  • 9. (c) 2015-16, No reproduction without permission Query ● Methods for getting data ● DTO's which are passed to the presentation layer for presentation ● Converting domain object to data might be complex, in CQRS we get DTOs directly from underlying data store
  • 10. (c) 2015-16, No reproduction without permission
  • 11. (c) 2015-16, No reproduction without permission Command Side ● Created by the client app and sent to the domain layer ● Messages that instruct the entity to perform some action
  • 12. (c) 2015-16, No reproduction without permission
  • 13. (c) 2015-16, No reproduction without permission Main Drivers ● Collaboration – Multiple actors / objects would be modifying the same set of data ● Staleness – The fact that once data has been shown to the user, it might have changed by another actor hence rendering it stale
  • 14. (c) 2015-16, No reproduction without permission
  • 15. (c) 2015-16, No reproduction without permission Queries on an additional datastore which can be slightly out of sync with the master but would server data in the form required by the presentation layer. The query data can be stored in any persistence mechanism right from being In memory to RDBMS
  • 16. (c) 2015-16, No reproduction without permission Commands need not be processed immediately, they can be queued. Consider the autonomous components to be actors where every actor is responsible for handling a group of related commands Since the domain model now does not serve queries, do we need relationship between entities on the domain model?
  • 17. (c) 2015-16, No reproduction without permission Example CustomerService ● void MakeCustomerPreferred(CustomerId) ● Customer GetCustomer(CustomerId) ● CustomerSet GetCustomersWithName(Name) ● CustomerSet GetPreferredCustomers() ● void ChangeCustomerLocale(CustomerId, NewLocale) ● void CreateCustomer(Customer) ● void EditCustomerDetails(CustomerDetails)
  • 18. (c) 2015-16, No reproduction without permission Example CustomerService ● void MakeCustomerPreferred(CustomerId) ● Customer GetCustomer(CustomerId) ● CustomerSet GetCustomersWithName(Name) ● CustomerSet GetPreferredCustomers() ● void ChangeCustomerLocale(CustomerId, NewLocale) ● void CreateCustomer(Customer) ● void EditCustomerDetails(CustomerDetails) What would you separate out?
  • 19. (c) 2015-16, No reproduction without permission Example CustomerWriteService ● void MakeCustomerPreferred(CustomerId) ● void ChangeCustomerLocale(CustomerId, NewLocale) ● void CreateCustomer(Customer) ● void EditCustomerDetails(CustomerDetails) CustomerReadService ● Customer GetCustomer(CustomerId) ● CustomerSet GetCustomersWithName(Name) ● CustomerSet GetPreferredCustomers()
  • 20. (c) 2015-16, No reproduction without permission Tying it up with Event Sourcing and Akka
  • 21. (c) 2015-16, No reproduction without permission Event Sourcing ● Event Sourcing means that all changes to application state are stored as a sequence of events. ● This sequence of events can be used to query the current state of an object but also the history of an object. ● Event sourcing allows one to create different kinds of views, even views which one did not even think of when creating the application. ● Because all events are stored, one can query the event store to create these new views based on the data- even at a later date.
  • 22. (c) 2015-16, No reproduction without permission Akka Persistence ● Event Sourcing review ● Persistent actor receives a command which is first validated and if successful, event(s) are generated. ● These events are persisted and if successfully persisted, change the actor's state ● When persistent actor needs to recover, persisted events are replayed. These events cannot fail
  • 23. (c) 2015-16, No reproduction without permission
  • 24. (c) 2015-16, No reproduction without permission Akka Persistence ● Command path implemented using PersistentActor ● Query path implemented using PersistentView
  • 25. (c) 2015-16, No reproduction without permission Example ● Create an Auction ● Place a did ● Query for the current winning bid ● Query for the bid history
  • 26. (c) 2015-16, No reproduction without permission REST Endpoints Or UI Command Handler Ack/nack Domain DB Event CacheQuery Handler
  • 27. (c) 2015-16, No reproduction without permission Command BidProcessor.scala. This is a PersistentActor
  • 28. (c) 2015-16, No reproduction without permission Query
  • 29. (c) 2015-16, No reproduction without permission
  • 30. (c) 2015-16, No reproduction without permission
  • 31. (c) 2015-16, No reproduction without permission Resources Full credits to the following and more resources for helping us with the understanding! Thank you! ● http://martinfowler.com/bliki/CQRS.html ● http://udidahan.com/2009/12/09/clarified-cqr s/ ● http://www.cqrsinfo.com/