Europe Virtual ALT.NET - EventStore v3

23
The CQRS EventStore Using and Abusing Europe Virtual ALT.NET, 25 October 2011 Jonathan Oliver

description

The slides from the Europe Virtual ALT.NET Presentation on the CQRS EventStore v3:http://blog.jonathanoliver.com/2011/10/eventstore-evan-presentation/

Transcript of Europe Virtual ALT.NET - EventStore v3

Page 1: Europe Virtual ALT.NET - EventStore v3

The CQRS EventStore

Using and Abusing

Europe Virtual ALT.NET, 25 October 2011

Jonathan Oliver

Page 2: Europe Virtual ALT.NET - EventStore v3

About Me—Jonathan Oliver

Founder: SmartyStreets (smartystreets.com)

Founder, co-host: Distributed Podcast

Committer, NServiceBus & Autofac

Project owner, CQRS EventStore

Page 3: Europe Virtual ALT.NET - EventStore v3

SmartyStreets

Finances the EventStore project

Started in 2006 (as Qualified Address)

All your street address are belong to us

My personal guinea pig

Fully geo-distributed

Page 4: Europe Virtual ALT.NET - EventStore v3

Prerequisites

Messaging

SOA

DDD

CQRS (strict definition)

Event Sourcing

CQRS Architecture

Page 5: Europe Virtual ALT.NET - EventStore v3

My CQRS Journey

Hand-crafted SQL and stored procedures

Canonical data model

Application integration via shared database

Generated DAL

Page 6: Europe Virtual ALT.NET - EventStore v3

My CQRS Journey (continued)

Temporal database design

Messaging

Breakthrough—Putting DBs in their place

Greg Young—InfoQ and DevTeach Videos

Page 7: Europe Virtual ALT.NET - EventStore v3

Event Sourcing

Capturing business intent

Rebuild state from events

Rewind, pause, fast-forward

Build alternate models

Immutable data is crazy scalable

Complete audit

Page 8: Europe Virtual ALT.NET - EventStore v3

Not Another Framework!

It’s not a framework—I hate frameworks

It doesn’t permeate your code

You can swap it out and/or build your own

Nothing existed at the time—March 2009

Implementation reflects the developer

Page 9: Europe Virtual ALT.NET - EventStore v3

Challenges and Considerations Goal: technology is an implementation

detail

Transactions typically exist in SQL land

Lots of interesting alternatives appearing

Momentum around NoSQL increasing

Two-phase commit virtually non-existent

Page 10: Europe Virtual ALT.NET - EventStore v3

Getting to the Correct Model

Absorbing transactions

Cross-resource transactional consistency

Commits

Exposing a robust, easy-to-use model

Page 11: Europe Virtual ALT.NET - EventStore v3

EventStore Model

Event Stream

Event Store

Persistence Engine

Durable Storage

“ISession”

“ISessionFactory”

“NHibernate Magic”

Disk, DB, Memory, etc.

Serializer

(Snapshotting and some advanced capabilities have been ommitted)

App / Service Layer“Repository”

Dispatcher / Bus

Pipeline Hooks

EventStore

commit

commit

Page 12: Europe Virtual ALT.NET - EventStore v3

Typical Workflow

Message Handler

EventStore

Disk

commit ack

Async Dispatch Scheduler

Transaction #1

•Optimistic Concurrency• Idempotency/De-duplication

Transaction #2

Transaction #3

Dispatch Scheduler

Messaging Technology

Wire Protocol

EventStore

Disk

Mark as dispatched

Page 13: Europe Virtual ALT.NET - EventStore v3

EventStore and Streams

Streams vs. Aggregates

Usage Example

Implementation

Page 14: Europe Virtual ALT.NET - EventStore v3

Pipeline Hooks

Pipes and filters

Filter out, modify, up-convert

Select, Precommit, and Postcommit

Implementation

Page 15: Europe Virtual ALT.NET - EventStore v3

Dispatchers

Synchronous vs. Asynchronous

Any bus, broker, or messaging technology

Any serialization mechanism

Production example

Implementation

Page 16: Europe Virtual ALT.NET - EventStore v3

Serialization

XML, JSON/BSON, Protocol Buffers, Thrift, MessagePack, Avro

Serialization pipeline

Implementation

Page 17: Europe Virtual ALT.NET - EventStore v3

SQL Storage Implementation

The primary storage engine

Easy to understand

Great management tools

Proven, mature implementation

10+ flavors (SQL Server, MySQL, SQLite, etc.)

Code

Page 18: Europe Virtual ALT.NET - EventStore v3

Raven Storage Implementation

Easy alternative for .NET

Great commercial support

Great management tools

Responsive community + Oren/Ayende

Gotcha: 2PC and repeatable reads

Page 19: Europe Virtual ALT.NET - EventStore v3

Mongo Storage Implementation

Highly robust engine

Established as a primary NoSQL engine

Lots of management tools

Code

Page 20: Europe Virtual ALT.NET - EventStore v3

Upcoming Implementations

CouchDB

Amazon

Azure

Oracle

Redis

Cassandra

.NET System.IO APIs

Page 21: Europe Virtual ALT.NET - EventStore v3

Wireup

Completely optional

Avoiding additional dependencies

Can use StructureMap, Autofac, Ninject, etc.

Page 22: Europe Virtual ALT.NET - EventStore v3

CommonDomain

Spike code that worked too well

Simple, opinionated “DDDD” framework

Purposefully minimalistic

“Essence” to be merged into EventStore

Page 23: Europe Virtual ALT.NET - EventStore v3

Thank You

Blog: blog.jonathanoliver.com

Twitter jonathan_oliver

GitHub github.com/joliver