Cqrs intro

15
CQ(R)S Command-Query Responsibility Segregation

description

In this session, Stefan Alaerts will run you through the basics of CQRS.

Transcript of Cqrs intro

Page 1: Cqrs intro

CQ(R)SCommand-Query Responsibility Segregation

Page 2: Cqrs intro

The typical CRUD architecture

http://en.wikipedia.org/wiki/Multitier_architecture

Page 3: Cqrs intro

Command and Query Soup

• MVC application: POST includes a command (intent to act) and returns a view based on a query.

• That doesn’t mean commands can’t have replies.Replies are in the form of “sure, I’ll do that” or “no problem, done”

Page 4: Cqrs intro

Command Query Separation (CQS)

• Queries: Return a result and do not change the observable state of the system (are free of side effects).

• Commands: Change the state of a system but do not return a value.

Bertrand Meyer

Page 5: Cqrs intro
Page 6: Cqrs intro
Page 7: Cqrs intro
Page 8: Cqrs intro

More buzz words

• Domain Driven Design

• Event/Message Based design

• Distributed Applications

• EventSourcing

• Test Driven Development

Page 9: Cqrs intro

Different kinds of ‘RS’

• EventSourcing + Reporting DB

• Different ViewModels for read and create/update (client level)

• Different databases or tables/views for read or write (DB level)

• …

Page 10: Cqrs intro

The hexagonal architecture

http://alistair.cockburn.us/Hexagonal+architecture

Page 11: Cqrs intro

Uncle Bob’s “Clean Architecture”

http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html

Page 12: Cqrs intro

Examples & Sources

• CQRS Journeyhttp://msdn.microsoft.com/en-us/library/jj554200.aspx

• CQRS, the book (Mark Nijhof)https://github.com/MarkNijhof/Fohjin

• Lokad-CQRShttps://github.com/lokad/lokad-cqrs/

• CQRS (Martin Fowler)http://martinfowler.com/bliki/CQRS.html

• Clarified CQRS (Udi Dahan)http://www.udidahan.com/2009/12/09/clarified-cqrs/

Page 13: Cqrs intro

Java Options

• Qi4j (framework for domain-centric application development)http://qi4j.org/

• Axon Framework (cqrs framework)http://www.axonframework.org/

• ServiceMixhttp://servicemix.apache.org/

• Don’t forget the roll-your-own-KISS-YAGNI solution!

Page 14: Cqrs intro

Demo Technology Stack

• Topshelf

• NServiceBus

• NancyFx

• OWIN

Page 15: Cqrs intro