5. CQRS – Why do we needit? FE Shop FE Administration BS Customer BS CRM
6. CQRS – Why do we needit? FE Shop FE Administration View Model Controller BS Customer BS CRM Service Layer DTO’s Services Domain (business logic) Data Access Layer
7. CQRS – Why do we needit? HTML View Model View Model Controller Service Layer SOAP / REST schema’s DTO’s Services Domain (business logic) Rows OO objects Data Access Layer
8. “How long wouldit take tocreate a screen likethis?” CQRS – WHY DO WE NEED IT?
9.
10. <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 !
11. Let’ssegregatequeriesandcommands Query: Query without transforming or mapping Show stale data whenever we can 2 Tier Data store foreachview (persisted views) Command: Talk in business events Keep all events as a truth Tell, don’task Asyncwhenever we can 3 Tier CQRS - to the rescue
12. CQRS - to the rescue UI UI DataStore Queries Subscribe EventBus Commands Business Logic Publish Truth (optional)
13. CQRS - to the rescue FE Shop FE Administration BS Customer BS CRM Events
14. Audit tracing Asyncby design Scalableby design Compensationable logic / conversations Close to the business Feature’s share no data/code = rapiddevelopment Best storage for best needs (ex: RDBMS forcommand processing, document basedfor UI datastore) Replayable Performance cannot get killedafteraddingthatone cool feature Rollout! Easy to unit test: Given <Previous Events> When <Command> is fired Then <New Events> expected CQRS - Advantages
15. Requiresalsoother view on specificationandtesting canbeconsideredan advantage Release management has tobe different (per feature style) disadantagebecause of oldstyle program managers Very hard toimplementcorrectly Needsmuch disc space Eventuallyconsistencyseemsscarryto most IT managers CQRS - DISADvantages
17. OpenSource project startedby 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
18. 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 lifetime 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 fired 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
25. MultiplayerDice website Part of QueueUnlimitedforshowing demo possibilities For more demo’s look at: NCQRS (http://ncqrs.org/) CQRS4J (http://code.google.com/p/cqrs4j/) For more detailed information look at: http://skillsmatter.com/podcast/open-source-dot-net/udi-dahan-command-query-responsibility-segregation http://www.infoq.com/interviews/dahan-cqrs-ddd-nservicebus DEMO