Skip to content

Commit 6f76057

Browse files
committed
Create a SagaManager events
1 parent d2dc035 commit 6f76057

20 files changed

Lines changed: 364 additions & 14 deletions

docker-compose.override.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ version: '2'
77
# An external IP or DNS name has to be used (instead localhost and the 10.0.75.1 IP) when testing the Web apps and the Xamarin apps from remote machines/devices using the same WiFi, for instance.
88

99
services:
10-
10+
sagamanager:
11+
environment:
12+
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
13+
- EventBusConnection=rabbitmq
14+
- GracePeriod=15 #In minutes
15+
1116
basket.api:
1217
environment:
1318
- ASPNETCORE_ENVIRONMENT=Development

docker-compose.vs.debug.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,16 @@ services:
120120
entrypoint: tail -f /dev/null
121121
labels:
122122
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
123+
124+
sagamanager:
125+
image: eshop/sagamanager:dev
126+
build:
127+
args:
128+
source: ${DOCKER_BUILD_SOURCE}
129+
volumes:
130+
- ./src/Services/SagaManager/SagaManager:/app
131+
- ~/.nuget/packages:/root/.nuget/packages:ro
132+
- ~/clrdbg:/clrdbg:ro
133+
entrypoint: tail -f /dev/null
134+
labels:
135+
- "com.microsoft.visualstudio.targetoperatingsystem=linux"

docker-compose.vs.release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,13 @@ services:
8080
entrypoint: tail -f /dev/null
8181
labels:
8282
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
83+
84+
sagamanager:
85+
build:
86+
args:
87+
source: ${DOCKER_BUILD_SOURCE}
88+
volumes:
89+
- ~/clrdbg:/clrdbg:ro
90+
entrypoint: tail -f /dev/null
91+
labels:
92+
- "com.microsoft.visualstudio.targetoperatingsystem=linux"

docker-compose.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
version: '2'
22

3+
34
services:
5+
sagamanager:
6+
image: eshop/sagamanager
7+
build:
8+
context: ./src/Services/SagaManager/SagaManager
9+
dockerfile: Dockerfile
10+
depends_on:
11+
- sql.data
12+
- rabbitmq
13+
414
basket.api:
515
image: eshop/basket.api
616
build:
@@ -9,7 +19,6 @@ services:
919
depends_on:
1020
- basket.data
1121
- identity.api
12-
- rabbitmq
1322

1423
catalog.api:
1524
image: eshop/catalog.api
@@ -35,6 +44,7 @@ services:
3544
dockerfile: Dockerfile
3645
depends_on:
3746
- sql.data
47+
- rabbitmq
3848

3949
webspa:
4050
image: eshop/webspa

eShopOnContainers-ServicesAndWebApps.sln

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26403.3
4+
VisualStudioVersion = 15.0.26403.7
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{932D8224-11F6-4D07-B109-DA28AD288A63}"
77
EndProject
@@ -78,6 +78,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Payment", "Payment", "{022E
7878
EndProject
7979
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Payment.API", "src\Services\Payment\Payment.API\Payment.API.csproj", "{1A01AF82-6FCB-464C-B39C-F127AEBD315D}"
8080
EndProject
81+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SagaManager", "SagaManager", "{F38B4FF0-0B49-405A-B1B4-F7A5E3BC4C4E}"
82+
EndProject
83+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SagaManager", "src\Services\SagaManager\SagaManager\SagaManager.csproj", "{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}"
84+
EndProject
8185
Global
8286
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8387
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@@ -1004,6 +1008,54 @@ Global
10041008
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x64.Build.0 = Release|Any CPU
10051009
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x86.ActiveCfg = Release|Any CPU
10061010
{1A01AF82-6FCB-464C-B39C-F127AEBD315D}.Release|x86.Build.0 = Release|Any CPU
1011+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
1012+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
1013+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
1014+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
1015+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
1016+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
1017+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1018+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
1019+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
1020+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
1021+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
1022+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
1023+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
1024+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|Any CPU.Build.0 = Debug|Any CPU
1025+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|ARM.ActiveCfg = Debug|Any CPU
1026+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|ARM.Build.0 = Debug|Any CPU
1027+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
1028+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|iPhone.Build.0 = Debug|Any CPU
1029+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1030+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
1031+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|x64.ActiveCfg = Debug|Any CPU
1032+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|x64.Build.0 = Debug|Any CPU
1033+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|x86.ActiveCfg = Debug|Any CPU
1034+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.AppStore|x86.Build.0 = Debug|Any CPU
1035+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1036+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|Any CPU.Build.0 = Debug|Any CPU
1037+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|ARM.ActiveCfg = Debug|Any CPU
1038+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|ARM.Build.0 = Debug|Any CPU
1039+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|iPhone.ActiveCfg = Debug|Any CPU
1040+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|iPhone.Build.0 = Debug|Any CPU
1041+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1042+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
1043+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|x64.ActiveCfg = Debug|Any CPU
1044+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|x64.Build.0 = Debug|Any CPU
1045+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|x86.ActiveCfg = Debug|Any CPU
1046+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Debug|x86.Build.0 = Debug|Any CPU
1047+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|Any CPU.ActiveCfg = Release|Any CPU
1048+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|Any CPU.Build.0 = Release|Any CPU
1049+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|ARM.ActiveCfg = Release|Any CPU
1050+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|ARM.Build.0 = Release|Any CPU
1051+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|iPhone.ActiveCfg = Release|Any CPU
1052+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|iPhone.Build.0 = Release|Any CPU
1053+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
1054+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
1055+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|x64.ActiveCfg = Release|Any CPU
1056+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|x64.Build.0 = Release|Any CPU
1057+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|x86.ActiveCfg = Release|Any CPU
1058+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47}.Release|x86.Build.0 = Release|Any CPU
10071059
EndGlobalSection
10081060
GlobalSection(SolutionProperties) = preSolution
10091061
HideSolutionNode = FALSE
@@ -1041,5 +1093,7 @@ Global
10411093
{D1C47FF1-91F1-4CAF-9ABB-AD642B821502} = {FBF43D93-F2E7-4FF8-B4AB-186895949B88}
10421094
{022E145D-1593-47EE-9608-8E323D3C63F5} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
10431095
{1A01AF82-6FCB-464C-B39C-F127AEBD315D} = {022E145D-1593-47EE-9608-8E323D3C63F5}
1096+
{F38B4FF0-0B49-405A-B1B4-F7A5E3BC4C4E} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
1097+
{F6E0F0DD-1400-43C3-B5E0-7CC325728C47} = {F38B4FF0-0B49-405A-B1B4-F7A5E3BC4C4E}
10441098
EndGlobalSection
10451099
EndGlobal
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62

73
namespace Ordering.API.Application.IntegrationCommands.Commands
84
{
95
public class ConfirmGracePeriodCommandMsg : IntegrationEvent
106
{
11-
public int OrderNumber { get; private set; }
7+
public int OrderId { get; }
128

13-
//TODO: message should change to Integration command type once command bus is implemented
9+
public ConfirmGracePeriodCommandMsg(int orderId) =>
10+
OrderId = orderId;
1411
}
1512
}

src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Ordering.Domain.Exceptions;
1111
using System;
1212
using System.Threading.Tasks;
13+
using Ordering.API.Application.IntegrationEvents.Events;
1314

1415
namespace Ordering.API.Application.Sagas
1516
{
@@ -73,13 +74,17 @@ public async Task Handle(SubmitOrderCommandMsg command)
7374
/// <returns></returns>
7475
public async Task Handle(ConfirmGracePeriodCommandMsg command)
7576
{
76-
var orderSaga = FindSagaById(command.OrderNumber);
77+
var orderSaga = FindSagaById(command.OrderId);
7778
CheckValidSagaId(orderSaga);
7879

7980
// TODO: This handler should change to Integration command handler type once command bus is implemented
80-
8181
// TODO: If order status is not cancelled, change state to awaitingValidation and
82-
// send ConfirmOrderStockCommandMsg to Inventory api
82+
// send ConfirmOrderStockCommandMsg to Inventory api
83+
if (orderSaga.OrderStatus == OrderStatus.Submitted)
84+
{
85+
86+
}
87+
8388
}
8489

8590

src/Services/Ordering/Ordering.API/Ordering.API.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
1414
</PropertyGroup>
1515

16+
<ItemGroup>
17+
<Compile Remove="Application\IntegrationEvents\EventHandling\**" />
18+
<Content Remove="Application\IntegrationEvents\EventHandling\**" />
19+
<EmbeddedResource Remove="Application\IntegrationEvents\EventHandling\**" />
20+
<None Remove="Application\IntegrationEvents\EventHandling\**" />
21+
</ItemGroup>
22+
1623
<ItemGroup>
1724
<Content Update="web.config;">
1825
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
@@ -80,7 +87,6 @@
8087

8188
<ItemGroup>
8289
<Folder Include="Application\IntegrationCommands\CommandHandlers\" />
83-
<Folder Include="Application\IntegrationEvents\EventHandling\" />
8490
<Folder Include="Infrastructure\IntegrationEventMigrations\" />
8591
</ItemGroup>
8692

src/Services/Ordering/Ordering.API/Startup.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Microsoft.eShopOnContainers.Services.Ordering.API
1+

2+
3+
namespace Microsoft.eShopOnContainers.Services.Ordering.API
24
{
35
using AspNetCore.Http;
46
using Autofac;
@@ -21,6 +23,9 @@
2123
using Microsoft.Extensions.DependencyInjection;
2224
using Microsoft.Extensions.HealthChecks;
2325
using Microsoft.Extensions.Logging;
26+
using Ordering.API.Application.Commands;
27+
using Ordering.API.Application.IntegrationCommands.Commands;
28+
using Ordering.API.Application.IntegrationEvents.Events;
2429
using Ordering.Infrastructure;
2530
using RabbitMQ.Client;
2631
using System;
@@ -157,6 +162,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
157162
.UseSqlServer(Configuration["ConnectionString"], b => b.MigrationsAssembly("Ordering.API"))
158163
.Options);
159164
integrationEventLogContext.Database.Migrate();
165+
166+
ConfigureEventBus(app);
160167
}
161168

162169
protected virtual void ConfigureAuth(IApplicationBuilder app)
@@ -169,5 +176,16 @@ protected virtual void ConfigureAuth(IApplicationBuilder app)
169176
RequireHttpsMetadata = false
170177
});
171178
}
179+
180+
protected virtual void ConfigureEventBus(IApplicationBuilder app)
181+
{
182+
var confirmGracePeriodHandler = app.ApplicationServices
183+
.GetService<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>();
184+
185+
var eventBus = app.ApplicationServices
186+
.GetRequiredService<IEventBus>();
187+
188+
eventBus.Subscribe<ConfirmGracePeriodCommandMsg>(confirmGracePeriodHandler);
189+
}
172190
}
173191
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!obj/Docker/publish/*
3+
!obj/Docker/empty/

0 commit comments

Comments
 (0)