You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ The **EventDriven.CQRS.Abstractions** library contains interfaces and abstract b
28
28
The **Reference Architecture** projects demonstrate how to apply these concepts to two microservices: `CustomerService` and `OrderService`. In addition, each service has *separate controllers for read and write operations*, thus segregating command and query responsibilities, with different sets of models, or Data Transfer Objects (DTO's).
29
29
-**Query Controller**: Uses repository to retrieve entities and converts them to DTO's with AutoMapper.
30
30
-**Command Controller**: Converts DTO's to domain entities using AutoMapper. Then hands control over to a command handler for executing business logic.
31
+
-**Command Broker**: Dispatches the command object to the correct command handler.
31
32
-**Command Handler**: Uses a domain entity to process commands which generate one or more domain events, then requests entity to apply the domain events in order to mutate entity state. Persists entity state to a state store and optionally publishes an integration event which is handled by another microservice.
32
33
-**Repository**: Persists entity state to a database.
33
34
-**Event Bus**: Used to publish integration events, as well as subscribe to events using an event handler. Dapr is used to abstract away the underlying pub/sub implementation. The default is Redis (for local development), but Dapr can be configured to use other components, such as AWS SNS+SQS.
@@ -87,9 +88,9 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
87
88
88
89
1. Add **Domain** and **CustomerAggregate** folders to the project, then add a `Customer` class that extends `Entity`.
89
90
- Add properties representing entity state.
90
-
- Create commands that are C# records and extend a `Command` base class.
91
+
- Create commands that are C# records and extend an `ICommand` interface with the result type as the generic.
91
92
```csharp
92
-
public record CreateCustomer(Customer Customer) : Command.Create(Customer.Id);
93
+
public record CreateCustomer(Customer Customer) : ICommand<CommandResult<Customer>>;
93
94
```
94
95
- Create domain events that extend `DomainEvent`.
95
96
```csharp
@@ -112,7 +113,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
112
113
- Inject `ICustomerRepository`, `IEventBus` and `IMapper` into the ctor.
113
114
- In the handler for `CreateCustomer`, write code to process the command, apply events, and persist the entity.
114
115
```csharp
115
-
public async Task<CommandResult<Customer>> Handle(CreateCustomer command)
116
+
public async Task<CommandResult<Customer>> Handle(CreateCustomer request, CancellationToken cancellationToken)
@@ -137,7 +138,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
137
138
```
138
139
- In the `UpdateCustomer` handler, see if the shipping address has changed, and if so, publish a `CustomerAddressUpdated` integration event, so that the order service can update the shipping address in the customer's orders.
139
140
```csharp
140
-
public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
141
+
public async Task<CommandResult<Customer>> Handle(UpdateCustomer request, CancellationToken cancellationToken)
0 commit comments