-
Notifications
You must be signed in to change notification settings - Fork 79
CQRS Process flows
Sam edited this page Jun 25, 2017
·
12 revisions
The first step in working with the CQRS.NET is understanding the ideal work/process flow, that is, how a request should flow a CQRS system; what steps, modules and class a request should travel through from start to end.
This article will discuss the idea of having a micro service based event driven architecture driving a service orientated architecture A.P.I... or end-point for a domain. This means that requests to the domain to modify state are asynchronous. At a high level, you start by making a request for state to be changed, receive a token for that request, and then await a response, or several responses, with a matching token.
Maybe via WCF.
- Send the command to the command bus.
- The command is received from the command bus.
- The corresponding command handler (only one can exist) is instantiated to handle the command.
- The command is passed into the command handler for processing.
Step 8 - Domain - Validate command
- The command is validated to make sure it adheres to basic requirements such as required fields are provided, strings match certain criteria, such as being an email address. Further details are available.
- An instance of an aggregate is created and instantiated.
- If the command is intended to change the state of an instance of an existing aggregate, the aggregate is rehydrated.
Step 11 - Domain - Apply command
- The command is applied. Business logic and rules are evaluated, state is not changed. Further details are available.
- Depending on the work flow taken based on your business logic and the commands values, one or more events are created.
- Send the event to the event bus.
- The event is applied to the aggregate, here the state if the aggregate is finally updated.
- The event is received from the event bus.
- The corresponding event handler(s) are instantiated to handle the event.
- The event is passed into each event handler for processing.
- Such as updating a projection.
- Such as publishing to front-end client via web-sockets.