17
PageUp People CQRS and Eventing Sourcing Abhaya Chauhan @AbhayaChauhan

CQRS and Eventing Sourcing

Embed Size (px)

Citation preview

PageUp People

CQRS and Eventing Sourcing

Abhaya Chauhan@AbhayaChauhan

Data Modelling - Third Normal Form

Performance with 3NF❖ Launching brand new product❖ 000s hits per second

Products

Product Comments Product Reviews

Product Inventory Best Sellers

Losing data❖ Who said it was okay to remove data?

User Shopping Cart

User Id Product Quantity

1 Tennis Racquet 1

1 Samsung Note 3 1

1 30” Monitor 2

DELETE FROM UserShoppingCart WHERE Product = ’30” Monitor’

Audit / History Logs

AccountId Balance When

1234 0 01 Jan 2015

1234 1000 05 Jan 2015

AccountId Balance

1234 $1000Trigger /

Event Based / Explicit

Account Account History

Event Sourced Shopping Cart

Cart Created

3 Items Added

1 Item Remove

dChecked

Out

WRITE SIDE

Task Based UI Projection

READ SIDE

Advantages of Event Sourcing

❖ Fantastic Performance❖ Events are appended only - forward only.❖ Allows our query model to be custom made for each Task Based UI

❖ Events are immutable❖ Very easy to scale up

❖ Easier to test❖ Reply events to replicate issues❖ Smoke test - Rerun REAL production scenarios

❖ Business Value - allows you to analyse behaviour and events❖ Not limited to “current state”

Standard Application Architecture

Command Query Responsibility Segregation

Eventual Consistency❖ Eventual Consistency sounds bad❖ But in reality, most of us are dealing with it without

realising.❖ Part of distributed computing - CAP Theorem

❖ Consistency❖ System Availability ❖ Network Partitioning

❖ Many ways to handle it

Task Based UI❖ a.k.a Inductive UIs❖ Opposite to CRUD UI❖ User Interface should be presented in terms of the

problem domain❖ Example

❖ User Interface should be presented for one task, in a clear fashion

❖ Works well with Domain Driven Design❖ Helps in naming Commands / Requests (Queries)

Event Driven Architecture

❖ This is a top level architecture pattern❖ Domain events are published❖ Anyone can subscribe to them❖ Medium - Message Bus❖ Execute a loosely coupled, cross system

workflow