+ All Categories
Home > Documents > CQRS & Queue unlimited

CQRS & Queue unlimited

Date post: 14-May-2015
Category:
Upload: tim-mahy
View: 1,477 times
Download: 1 times
Share this document with a friend
Popular Tags:
25
ISKA 08/2010 CQRS & QUEUEUNLIMITED
Transcript
Page 1: CQRS & Queue unlimited

ISKA 08/2010

CQRS & QUEUEUNLIMITED

Page 2: CQRS & Queue unlimited

Introduction to CQRS pattern

QueueUnlimited concepts and implementation

Demo

WHAT WE ARE GOING TO SEE

Page 3: CQRS & Queue unlimited

“Crack” for architects

CQRS

Page 4: CQRS & Queue unlimited

CommandQueryResponsibility Segregation

CQRS

Page 5: CQRS & Queue unlimited

CQRS – WHY DO WE NEED IT?

BS Customer BS CRM

FE ShopFE

Administration

Page 6: CQRS & Queue unlimited

CQRS – WHY DO WE NEED IT?

BS Customer BS CRM

FE ShopFE

Administration Model View

Controller

Service

Layer

DTO’s

ServicesDomain (business

logic)Data Access Layer

Page 7: CQRS & Queue unlimited

CQRS – WHY DO WE NEED IT?

Model View

Controller

Service

Layer

DTO’s

ServicesDomain (business

logic)Data Access Layer

SOAP / REST schema’s

OO objects Rows

View Model

HTML

Page 8: CQRS & Queue unlimited

“How long would it take to create a screen like this?”

CQRS – WHY DO WE NEED IT?

Page 9: CQRS & Queue unlimited

In a traditional 3 layered SOA: Small changes = relative big impact Performance problems are very hard to solve Mapping, mapping mapping Serialization, Serialization, … Authorization hell All layers are coupled

(I know you don’t want to hear this, but is the truth !)

CQRS – WHY DO WE NEED IT?

Page 10: CQRS & Queue unlimited

<asp:DataList ID="DataList1" runat="server" DataSourceID="LastUsersDataSource"> <ItemTemplate> <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /> <br /> </ItemTemplate></asp:DataList>

<asp:SqlDataSource ID="LastUsersDataSource" runat="server" ConnectionString="<%$ ConnectionStringsMyConnectionString %>" SelectCommand="SELECT [Name], [InsertDateTime] FROM [LastUsers] ORDER BY [InsertDateTime] DESC "></asp:SqlDataSource>

MS DEMO’S RULE !

Page 11: CQRS & Queue unlimited

Let’s segregate queries and commandsQuery:

Query without transforming or mapping Show stale data whenever we can 2 Tier Data store for each view (persisted views)

Command: Talk in business events Keep all events as a truth Tell, don’t ask Async whenever we can 3 Tier

CQRS - TO THE RESCUE

Page 12: CQRS & Queue unlimited

CQRS - TO THE RESCUE

UI

UI DataStore

Truth (optional)

Business Logic

Commands

Queries

EventBus

Subscribe

Publish

Page 13: CQRS & Queue unlimited

CQRS - TO THE RESCUE

BS Customer BS CRM

FE ShopFE

Administration

Events

Page 14: CQRS & Queue unlimited

Audit tracing Async by design Scalable by design Compensationable logic / conversations Close to the business Feature’s share no data/code = rapid development Best storage for best needs (ex: RDBMS for command

processing, document based for UI datastore) Replayable Performance cannot get killed after adding that one cool

feature Rollout! Easy to unit test:

Given <Previous Events> When <Command> is fired Then <New Events> expected

CQRS - ADVANTAGES

Page 15: CQRS & Queue unlimited

Requires also other view on specification and testing can be considered an advantage

Release management has to be diff erent (per feature style) disadantage because of old style program managers

Very hard to implement correctlyNeeds much disc space Eventually consistency seems scarry to most IT

managers

CQRS - DISADVANTAGES

Page 16: CQRS & Queue unlimited

QueueUnlimited

Page 17: CQRS & Queue unlimited

OpenSource project started by Marc Rexwinkel en Tim Mahy

http://queueunlimited.codeplex.com/

For current customer platform: Sql Server 2008 R2 Sql Server Service Broker .NET 3.5

QUEUE UNLIMITED

Page 18: CQRS & Queue unlimited

A queue like data store that allows asynchronous processing A data store that can distribute it’s messages to multiple

subscribers A data store that can perform a replay of it’s messages (from a

certain period or all messages) A data store that can check retention l ifetime of messages and

remove them when necessary A data store that can optionally send all previous messages to a

subscriber that is added a long time after an message was fi red A data store that is manageable through default tooling

(performance monitoring, intervening when production problems occur, backup …)

A data store that can scale up or scale out A data store that can preserve the ordering of messages inside

groups (functional partitioning) A data store that is fully ACID without a two phase commit (so no

DTC)

QUEUE UNLIMITED

Page 19: CQRS & Queue unlimited

Uses only Stored Procedures Implemented using SSB

QUEUE UNLIMITED

Page 20: CQRS & Queue unlimited

How it works

QUEUE UNLIMITED – NO SUBSCRIBERS

PublishEvent SP

Root Queue

InitiatorService

RootService

Page 21: CQRS & Queue unlimited

QUEUE UNLIMITED – ADDING A SUBSCRIBER

PublishEvent SP

Root Queue

InitiatorService

RootService

RootQueueActivation SP

Activated

Subscriber 1 Queue

Replay 1 Queue

Generated SP

Not activated

Replay 1 InitiatorService

Subscriber InitiatorService

Subscriber ReceiveService Replay 1 ReceiveService

Some app

Page 22: CQRS & Queue unlimited

QUEUE UNLIMITED – ADDING ANOTHER SUBSCRIBER

SendEvent SP

Root Queue

Initiator service

Receive Service

Distribute SP

Activated

Subscriber 1 Queue

Replay 1 Queue

Distribute 3 SP

Initiator service 3

Initiator service 2

Receive Service 2

Receive Service 3

Activated

Subscriber 2 Queue

Replay 2 Queue

Distribute 4 SP

Initiator service 5

Initiator service 4

Receive Service 4Receive Service

5 Not activated

Some app

Some app

Page 23: CQRS & Queue unlimited

QUEUE UNLIMITED – GARBAGE COLLECTION

SendEvent SP

Root Queue

Initiator service

Receive Service

Distribute SP

Activated

Subscriber 1 Queue

Replay 2 Queue

Distribute 4 SP

Initiator service 5

Initiator service 2

Receive Service 2

Receive Service 5

Not activate

d

Subscriber 2 Queue

Initiator service 4

Receive Service 4

Some appSome app

Page 24: CQRS & Queue unlimited

Open for some fresh developers

QUEUE UNLIMITED


Recommended