Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Meetup Paris TypeScript #19 - CQRS with Nest.js

Meetup Paris TypeScript #19 - CQRS with Nest.js

Quick presentation of CQRS with a demo (Nest.js & CosmosDB)

Content based on the presentation I did during the GAB Rennes 2019 (https://speakerdeck.com/spontoreau/microservices-azure-cosmos-db-to-rule-them-all)

Sylvain PONTOREAU

June 04, 2019
Tweet

More Decks by Sylvain PONTOREAU

Other Decks in Programming

Transcript

  1. Data Driven Development Domain Driven Design Domain Driven Development !=

    Data structure MCD CRUD Behavior Bounded Context Event
  2. CQRS GetOrderById Query UpdateProduct Command GetProducts Query DeleteOrder Command …

    … Dispatcher Dispatcher QueryHandler CommandHandler Validation Plugin Monitoring Plugin Telemetry Plugin … Eventual consistency
  3. Consistency • All system nodes needs to manipulate exactly the

    same data at the same time. Availability Partition tolerance • Requests must succeed. • Node failure must not create a complete system failure. A distributed system can only guarantee 2 constrains at the same time, not 3… you have to embrace eventual consistency when building Microservices! Eventual consistency?
  4. CQRS & Event Sourcing GetOrderById Query UpdateProduct Command GetProducts Query

    DeleteOrder Command … … Dispatcher Dispatcher QueryHandler CommandHandler Projection Projection Aggregate State Events
  5. Cosmos DB as an Event Store Read Enpoint Write Enpoint

    Event Store Projector Read DB publish trigger persist query