SlideShare ist ein Scribd-Unternehmen logo
1 von 16
CQRS
USING WINDOWS AZURE SERVICE BUS
¿Quiénes somos?

Luis Ruiz Pavón
@luisruizpavon

Roberto González
@robertogg
CQRS
 CQRS = “Command Query Responsibility Segregation”
 A design – pattern -architecture – Framework – Principle –
Something

3
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.”

4
Benefits of CQRS
 Isolated changes to the application
 User Interface can change with zero impact to storage
 Storage can be changed with zero impact to UI

 Availability is very high, as all reads are unblocked
Queries
 90%+ of access to our applications are READS from the datastore
 Very Fast

 Eventual Consistency
 Cache It
Commands
 Commands are directives to the domain to perform some action
 Commands may be declined/rejected by the domain for various reasons

 Processing a Command will result in 0:n Events raised
 Commands are always in the imperative:
 PlaceOrder, not OrderPlaced

 Handler per command
 Command can be queued
 Split into separate queues
Demystifying Commands
public class PlaceOrderCommand

{
//properties
public readonly Guid OrderId;
public readonly string Comment;

//ctor
public PlaceOrderCommand(Guid id, string comment)
{
OrderId = id;
Comment = comment;
}
}
Events
 Events are the result of some action having already happened in the Domain
 Events may never be declined/rejected; they are evidence that something
already happened
 Events are always in the past-tense:
 OrderPlaced, not PlaceOrder
Eventual Consistency
 Property of a system such that not all records of state guaranteed
to agree at any given point in time.
 Applicable to whole systems or parts of systems (such as a database)

 As opposed to Strongly Consistent (or Instantly Consistent)
 Eventual Consistency is natural characteristic of a useful, scalable
distributed systems
Why Eventual Consistency?
CAP Theorem
Consistency: all nodes see the same data at
the same time
Availability: a guarantee that every request
receives a response about whether it was
successful or failed)
Partition tolerance: the system continues to
operate despite arbitrary message loss
From: http://en.wikipedia.org/wiki/CAP_theorem
CQRS in Windows Azure
WE NEED:

 Compute resource to run our code

Web Roles (IIS) and Worker Roles (w/o IIS)

 Reliable Queue to communicate
Windows Azure Service Bus Queues

 Durable/Persistent Storage
SQL Azure

 Fast View

Azure Cache + NoSQL
Should I do CQRS?
… “Probably Not” 
Links
Udi Dahan: http://www.udidahan.com
Greg Young: http://goodenoughsoftware.net/
CQRS Documents: http://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf

Weitere ähnliche Inhalte

Andere mochten auch

Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement ConferenceAdobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
Cathy Yandow
 
11 Dez Discussion Platform 2 - Ali Ordubadi
11 Dez Discussion Platform 2 - Ali Ordubadi11 Dez Discussion Platform 2 - Ali Ordubadi
11 Dez Discussion Platform 2 - Ali Ordubadi
PANF08
 
ACTFL Best of Toys 2011 3 modes presentation
ACTFL Best of Toys 2011  3 modes presentation ACTFL Best of Toys 2011  3 modes presentation
ACTFL Best of Toys 2011 3 modes presentation
Toni Theisen
 
Newsletter AudiSEC Sàrl Prévention SST
Newsletter AudiSEC Sàrl Prévention SSTNewsletter AudiSEC Sàrl Prévention SST
Newsletter AudiSEC Sàrl Prévention SST
valerienaef
 
Conductisme autors: wikipedia
Conductisme autors: wikipediaConductisme autors: wikipedia
Conductisme autors: wikipedia
anukaf
 
Dp net aan ws presentation cca&drr
Dp net aan ws presentation cca&drrDp net aan ws presentation cca&drr
Dp net aan ws presentation cca&drr
DPNet
 

Andere mochten auch (18)

Apache HTTP y Moodle
Apache HTTP y MoodleApache HTTP y Moodle
Apache HTTP y Moodle
 
Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement ConferenceAdobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
Adobe Acrobat Pro X - 2014 UVM Extension Professional Improvement Conference
 
11 Dez Discussion Platform 2 - Ali Ordubadi
11 Dez Discussion Platform 2 - Ali Ordubadi11 Dez Discussion Platform 2 - Ali Ordubadi
11 Dez Discussion Platform 2 - Ali Ordubadi
 
Catálogo Lorpen - Inverno 2011
Catálogo Lorpen - Inverno 2011Catálogo Lorpen - Inverno 2011
Catálogo Lorpen - Inverno 2011
 
ACTFL Best of Toys 2011 3 modes presentation
ACTFL Best of Toys 2011  3 modes presentation ACTFL Best of Toys 2011  3 modes presentation
ACTFL Best of Toys 2011 3 modes presentation
 
Newsletter AudiSEC Sàrl Prévention SST
Newsletter AudiSEC Sàrl Prévention SSTNewsletter AudiSEC Sàrl Prévention SST
Newsletter AudiSEC Sàrl Prévention SST
 
Charles dellschau
Charles dellschau Charles dellschau
Charles dellschau
 
Estrategias de ventas por internet en el Sector Turístico
Estrategias de ventas por internet en el Sector TurísticoEstrategias de ventas por internet en el Sector Turístico
Estrategias de ventas por internet en el Sector Turístico
 
Persuasion Labs - The Basics
Persuasion Labs - The BasicsPersuasion Labs - The Basics
Persuasion Labs - The Basics
 
Cerámicas y sanitarios Gala
Cerámicas y sanitarios GalaCerámicas y sanitarios Gala
Cerámicas y sanitarios Gala
 
Medicina Bucal. Dr. Moses Grimaldo Carjevschi
Medicina Bucal. Dr. Moses Grimaldo CarjevschiMedicina Bucal. Dr. Moses Grimaldo Carjevschi
Medicina Bucal. Dr. Moses Grimaldo Carjevschi
 
Conductisme autors: wikipedia
Conductisme autors: wikipediaConductisme autors: wikipedia
Conductisme autors: wikipedia
 
disaster management
disaster managementdisaster management
disaster management
 
05 SEO - Factores internos de la optimizacion web
05 SEO - Factores internos de la optimizacion web05 SEO - Factores internos de la optimizacion web
05 SEO - Factores internos de la optimizacion web
 
Actividad integrada
Actividad integradaActividad integrada
Actividad integrada
 
Dp net aan ws presentation cca&drr
Dp net aan ws presentation cca&drrDp net aan ws presentation cca&drr
Dp net aan ws presentation cca&drr
 
Chartnexus manual for learning
Chartnexus manual for learningChartnexus manual for learning
Chartnexus manual for learning
 
Using mappings, affordances, constraints and signifiers in ux
Using mappings, affordances, constraints and signifiers in uxUsing mappings, affordances, constraints and signifiers in ux
Using mappings, affordances, constraints and signifiers in ux
 

Mehr von Luis Ruiz Pavón

Gwab diseño de arquitecturas escalables con cqrs
Gwab   diseño de arquitecturas escalables con cqrsGwab   diseño de arquitecturas escalables con cqrs
Gwab diseño de arquitecturas escalables con cqrs
Luis Ruiz Pavón
 

Mehr von Luis Ruiz Pavón (12)

OAuth2 para desarrolladores
OAuth2 para desarrolladoresOAuth2 para desarrolladores
OAuth2 para desarrolladores
 
Patrones de diseño de software en la creación de microservicios
Patrones de diseño de software en la creación de microserviciosPatrones de diseño de software en la creación de microservicios
Patrones de diseño de software en la creación de microservicios
 
Servicios comunes en .NET Core
Servicios comunes en .NET CoreServicios comunes en .NET Core
Servicios comunes en .NET Core
 
.NET Core 1.0 y ASP.NET Core 1.0
.NET Core 1.0 y ASP.NET Core 1.0.NET Core 1.0 y ASP.NET Core 1.0
.NET Core 1.0 y ASP.NET Core 1.0
 
ReConnect 2015 - ASP.NET 5: MVC 6 y EF 7
ReConnect 2015  - ASP.NET 5: MVC 6 y EF 7ReConnect 2015  - ASP.NET 5: MVC 6 y EF 7
ReConnect 2015 - ASP.NET 5: MVC 6 y EF 7
 
ASP.NET 5 en Linux y Mac OS X: herramientas e integración
ASP.NET 5 en Linux y Mac OS X: herramientas e integraciónASP.NET 5 en Linux y Mac OS X: herramientas e integración
ASP.NET 5 en Linux y Mac OS X: herramientas e integración
 
#Dean document db + express + angularjs + nodejs running on azure
#Dean document db + express + angularjs + nodejs running on azure#Dean document db + express + angularjs + nodejs running on azure
#Dean document db + express + angularjs + nodejs running on azure
 
Como hago yo asp.net mvc dot netspainconference 2015
Como hago yo asp.net mvc   dot netspainconference 2015Como hago yo asp.net mvc   dot netspainconference 2015
Como hago yo asp.net mvc dot netspainconference 2015
 
Foro arquitectos de Microsoft 2015 - CQRS/ES Cambiando tu forma de pensar
Foro arquitectos de Microsoft 2015 - CQRS/ES Cambiando tu forma de pensarForo arquitectos de Microsoft 2015 - CQRS/ES Cambiando tu forma de pensar
Foro arquitectos de Microsoft 2015 - CQRS/ES Cambiando tu forma de pensar
 
JavaScript para desarrolladores c#
JavaScript para desarrolladores c#JavaScript para desarrolladores c#
JavaScript para desarrolladores c#
 
La calidad de código importa
La calidad de código importaLa calidad de código importa
La calidad de código importa
 
Gwab diseño de arquitecturas escalables con cqrs
Gwab   diseño de arquitecturas escalables con cqrsGwab   diseño de arquitecturas escalables con cqrs
Gwab diseño de arquitecturas escalables con cqrs
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

CQRS con Windows Azure Service Bus y SignalR

  • 2. ¿Quiénes somos? Luis Ruiz Pavón @luisruizpavon Roberto González @robertogg
  • 3. CQRS  CQRS = “Command Query Responsibility Segregation”  A design – pattern -architecture – Framework – Principle – Something 3
  • 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.” 4
  • 5. Benefits of CQRS  Isolated changes to the application  User Interface can change with zero impact to storage  Storage can be changed with zero impact to UI  Availability is very high, as all reads are unblocked
  • 6.
  • 7.
  • 8. Queries  90%+ of access to our applications are READS from the datastore  Very Fast  Eventual Consistency  Cache It
  • 9. Commands  Commands are directives to the domain to perform some action  Commands may be declined/rejected by the domain for various reasons  Processing a Command will result in 0:n Events raised  Commands are always in the imperative:  PlaceOrder, not OrderPlaced  Handler per command  Command can be queued  Split into separate queues
  • 10. Demystifying Commands public class PlaceOrderCommand { //properties public readonly Guid OrderId; public readonly string Comment; //ctor public PlaceOrderCommand(Guid id, string comment) { OrderId = id; Comment = comment; } }
  • 11. Events  Events are the result of some action having already happened in the Domain  Events may never be declined/rejected; they are evidence that something already happened  Events are always in the past-tense:  OrderPlaced, not PlaceOrder
  • 12. Eventual Consistency  Property of a system such that not all records of state guaranteed to agree at any given point in time.  Applicable to whole systems or parts of systems (such as a database)  As opposed to Strongly Consistent (or Instantly Consistent)  Eventual Consistency is natural characteristic of a useful, scalable distributed systems
  • 13. Why Eventual Consistency? CAP Theorem Consistency: all nodes see the same data at the same time Availability: a guarantee that every request receives a response about whether it was successful or failed) Partition tolerance: the system continues to operate despite arbitrary message loss From: http://en.wikipedia.org/wiki/CAP_theorem
  • 14. CQRS in Windows Azure WE NEED:  Compute resource to run our code Web Roles (IIS) and Worker Roles (w/o IIS)  Reliable Queue to communicate Windows Azure Service Bus Queues  Durable/Persistent Storage SQL Azure  Fast View Azure Cache + NoSQL
  • 15. Should I do CQRS? … “Probably Not” 
  • 16. Links Udi Dahan: http://www.udidahan.com Greg Young: http://goodenoughsoftware.net/ CQRS Documents: http://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf