a practical introduction to event sourcing and cqrs

37
A practical introduction to Event Sourcing and Command Query Responsibility Segregation

Upload: robert-lemke

Post on 08-Apr-2017

66 views

Category:

Technology


1 download

TRANSCRIPT

A practical introduction to Event Sourcing and Command Query Responsibility Segregation

Robert Lemke

CEO FlownativeProject Founder [email protected]@robertlemke

CRUD

Create, Read, Update, Delete

CQRS

Command QueryResponsibility Segragation

Event Sourcing

Store all changes to the system, rather than it’s current state.

Event Sourcing

Store all changes to the system, rather than it’s current state.

Mathias Verraes (http://verraes.net)

Motivation for Event Sourcing

Expressivity

Distributed /event-driven architecture

Audit log*

Debugging

New representations / analysis

Easy storage

Commands

Do that! (imperative)

Command Handlers will handle commands. They don’t return a result, only accept or reject commands.

$commandHandler->handle($command);

Events

Domain Events: something interesting in the domain / business

(infrastructure) events: user clicked button, log has been rotated, file upload failed

Events are something which happened in the past

You can’t change the past, so events are immutable

Event Sourcing does not need a framework.

But Neos.EventSourcing helps you implementing Event Sourcing with Flow.

The sample domain

addBookToAssortment addBookToCatalog addBookToListOfProductsPeopleCanBuy ;-)

Live Demo 😱

Some special cases

Deleting a book

Media / assets / binary data

Flow accounts, …

Versioning events

Should you try it?

[email protected] www.flownative.com

@robertlemke

your thoughts?