1. CQRS is an architectural pattern that separates commands and queries based on the Command Query Responsibility Segregation (CQRS) principle.
2. MediatR is a .NET library that implements the mediator pattern to support request/response and publish/subscribe interactions using CQRS. It allows defining commands, handlers, and processing asynchronously or synchronously in a simple way.
3. Brighter is another .NET library that supports CQRS with additional features like command dispatching, processing pipelines, and quality of service policies for timeout, retry, and circuit breaking patterns. It requires more manual configuration than MediatR.
10. Standard approach: problems
Shared entities:
• Promote procedural style instead of OO
• Ineffective reads in Data Access layer (ORM loads whole object, even
if you need only some fields)
https://en.wikipedia.org/wiki/Anemic_domain_model
https://martinfowler.com/bliki/AnemicDomainModel.html
13. CQRS is not
• An architecture
• A guiding principle (CQS is)
• An eventual consistency
• Messaging
• And also does not require message bus
• Having separate models for reading and writing
• Event sourcing
• Linked to DDD
14. CQRS is
• Architectural pattern
• First described by Greg Young
• Based on Command & Query Separation (CQS) principle
• Simple enough to be described in 5 minutes
15. Command & Query Separation principle
• Object’ methods are either Queries or Commands
• Queries return value (data) and do not change system state
• Commands change system state and do not return values
16. CQRS
• Stands for Command Query Responsibility Segregation
• Maintains CQS viewpoint
• Essentially, CQS + splitting object into Command and Query parts
29. Brighter Configuration
• Requires some manual commands and handlers registration
• Also supports quality of service (QoS) policies
• Timeout pattern
• Retry pattern
• Circuit-Breaker pattern
• Is in active development, so there might be a mess in documentation
sometimes, missing/obsolete pieces, etc (issue a pull request )
30. More libs
• Mass Transit
• Rebus
• NServiceBus
All of them are rather messaging frameworks for interprocess
communication
31. Summary
1. CQRS is not for all apps (and not for the whole app)
2. MediatR – concise, simple, easy to start
3. Brighter – seems to be more powerful, sometimes hard to grasp
4. Do manage complexity in your business logic!