Skip to content

Commit 9af2f90

Browse files
author
Anthony Sneed
committed
Add support for EventDriven.EventBus.Dapr.EventCache.Mongo.
1 parent 96f3c73 commit 9af2f90

22 files changed

+91
-49
lines changed

EventDriven.CQRS.sln

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ EndProject
1111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{269CD137-4093-4100-B33E-808586D335F6}"
1212
EndProject
1313
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "reference-architecture", "reference-architecture", "{C4FD0AF1-927A-4860-A634-7CE342807692}"
14-
ProjectSection(SolutionItems) = preProject
15-
reference-architecture\dapr\components\pubsub.yaml = reference-architecture\dapr\components\pubsub.yaml
16-
reference-architecture\dapr\components\snssqs-pubsub.yaml = reference-architecture\dapr\components\snssqs-pubsub.yaml
17-
EndProjectSection
1814
EndProject
1915
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventDriven.CQRS.Tests", "test\EventDriven.CQRS.Tests\EventDriven.CQRS.Tests.csproj", "{9809006C-2F6B-44A1-8AE2-BC449368D209}"
2016
EndProject
@@ -35,7 +31,9 @@ EndProject
3531
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", "{00BA9501-787E-465C-97D0-F51295D97802}"
3632
ProjectSection(SolutionItems) = preProject
3733
reference-architecture\dapr\components\pubsub.yaml = reference-architecture\dapr\components\pubsub.yaml
38-
reference-architecture\dapr\components\snssqs-pubsub.yaml = reference-architecture\dapr\components\snssqs-pubsub.yaml
34+
reference-architecture\dapr\components\pubsub-snssqs.yaml = reference-architecture\dapr\components\pubsub-snssqs.yaml
35+
reference-architecture\dapr\components\statestore-mongodb.yaml = reference-architecture\dapr\components\statestore-mongodb.yaml
36+
reference-architecture\dapr\components\statestore.yaml = reference-architecture\dapr\components\statestore.yaml
3937
EndProjectSection
4038
EndProject
4139
Global

ReadMe.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
4646
dapr run --app-id order-service --app-port 5150 --components-path ../dapr/components -- dotnet run
4747
```
4848
4. Create some customers.
49-
- Open http://localhost:5000/swagger
49+
- Open http://localhost:5656/swagger
5050
- Execute posts using contents of **customers.json**.
5151
- Copy post response, modify fields, then execute puts.
5252
- Make sure to copy `etag` value from last response, or you will get a concurrency error.
5353
- Copy `id` and `etag` values to execute deletes.
5454
- Execute gets to retrieve customers.
5555
- View customers database collections using Robo 3T.
5656
5. Create some orders.
57+
- Open http://localhost:5757/swagger
5758
- Execute posts using contents of **orders.json**.
5859
- Copy post response, modify fields, then execute puts.
5960
- Make sure to copy `etag` value from last response, or you will get a concurrency error.
@@ -63,15 +64,12 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
6364
6. Update the address of a customer who has order.
6465
- Note the address is also updated for the customer's orders.
6566
- Observe log messages in terminal when integration events are published and handled.
66-
7. To **debug** services, you will need to use **Visual Studio Code** with the *Dapr extension*.
67-
- Open instances of VS Code at both CustomerService and OrderService.
68-
- If .vscode folder not present:
69-
- First create build and debug artifacts.
70-
- Then from the task palette run `Dapr: Scaffold Dapr Tasks`.
71-
- Enter values for launch, app id (customer-service) and port (5000).
72-
- Enter values for launch, app id (order-service) and port (5050).
73-
- Switch to the Debug tab and select "with Dapr" configuration.
74-
- Set breakpoints as needed and press F5 to start debugging.
67+
7. To **debug** services, you can use [tye](https://github.com/dotnet/tye) with the *Dapr extension*.
68+
- Open a terminal at the reference-architecture folder.
69+
- Run `tye run --debug *`
70+
- Set breakpoints in each project.
71+
- Attach the debugger to each process.
72+
- Open http://localhost:8000 to view the Tye Dashboard.
7573
7674
### Development Guide
7775

reference-architecture/Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="EventDriven.EventBus.Abstractions" Version="1.1.0" />
8+
<PackageReference Include="EventDriven.EventBus.Abstractions" Version="1.2.0-beta2" />
99
</ItemGroup>
1010

1111
</Project>

reference-architecture/CustomerService/CustomerService.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
8+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
99
<PackageReference Include="EventDriven.DDD.Abstractions" Version="1.1.0-beta2" />
1010
<PackageReference Include="EventDriven.DependencyInjection.URF.Mongo" Version="1.1.0-beta3" />
11-
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.2.0-beta1" />
11+
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.2.0-beta2" />
12+
<PackageReference Include="EventDriven.EventBus.Dapr.EventCache.Mongo" Version="1.2.0-beta2" />
1213
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
1314
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
1415
<PackageReference Include="URF.Core.Mongo" Version="3.1.3" />

reference-architecture/CustomerService/Domain/CustomerAggregate/CommandHandlers/CustomerCommandHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
5252
// Compare shipping addresses
5353
_logger.LogInformation("Handling command: {CommandName}", nameof(UpdateCustomer));
5454
var existing = await _repository.Get(command.EntityId);
55+
if (existing == null) return new CommandResult<Customer>(CommandOutcome.NotHandled);
5556
var addressChanged = command.Entity.ShippingAddress != existing.ShippingAddress;
5657

5758
try

reference-architecture/CustomerService/Domain/CustomerAggregate/Customer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public CustomerCreated Process(CreateCustomer command)
2222

2323
public void Apply(CustomerCreated domainEvent) =>
2424
// Set Id
25-
Id = domainEvent.EntityId != default(Guid) ? domainEvent.EntityId : Guid.NewGuid();
25+
Id = domainEvent.EntityId != default ? domainEvent.EntityId : Guid.NewGuid();
2626
}
2727
}

reference-architecture/CustomerService/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dotnetRunMessages": "true",
77
"launchBrowser": true,
88
"launchUrl": "swagger",
9-
"applicationUrl": "http://localhost:5000",
9+
"applicationUrl": "http://localhost:5656",
1010
"environmentVariables": {
1111
"ASPNETCORE_ENVIRONMENT": "Development"
1212
}

reference-architecture/CustomerService/Startup.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public void ConfigureServices(IServiceCollection services)
3838

3939
// Add Dapr event bus
4040
services.AddDaprEventBus(Configuration, true);
41+
42+
// Add Dapr Mongo event cache
43+
services.AddDaprMongoEventCache(Configuration);
4144
}
4245

4346
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

reference-architecture/CustomerService/appsettings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
"DaprEventBusOptions": {
1616
"PubSubName": "pubsub"
1717
},
18+
"DaprEventCacheOptions": {
19+
"DaprStateStoreOptions": {
20+
"StateStoreName": "statestore-mongodb"
21+
}
22+
},
23+
"DaprStoreDatabaseSettings": {
24+
"ConnectionString": "mongodb://localhost:27017",
25+
"DatabaseName": "daprStore",
26+
"CollectionName": "daprCollection"
27+
},
1828
"DaprEventBusSchemaOptions": {
1929
"UseSchemaRegistry": true,
2030
"SchemaValidatorType": "Json",

reference-architecture/OrderService/OrderService.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
8+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
99
<PackageReference Include="EventDriven.DDD.Abstractions" Version="1.1.0-beta2" />
1010
<PackageReference Include="EventDriven.DependencyInjection.URF.Mongo" Version="1.1.0-beta3" />
11-
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.2.0-beta1" />
11+
<PackageReference Include="EventDriven.EventBus.Dapr" Version="1.2.0-beta2" />
12+
<PackageReference Include="EventDriven.EventBus.Dapr.EventCache.Mongo" Version="1.2.0-beta2" />
1213
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
1314
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
1415
<PackageReference Include="URF.Core.Mongo" Version="3.1.3" />

0 commit comments

Comments
 (0)