Skip to content

Commit 8dc176a

Browse files
author
Ramón Tomás
committed
Fixed issue #291ordering.api fails after submitting orders
1 parent 01469da commit 8dc176a

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using Autofac;
2+
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
3+
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
24
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries;
35
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
46
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
57
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
68
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories;
9+
using System.Reflection;
710

811
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules
912
{
@@ -38,6 +41,10 @@ protected override void Load(ContainerBuilder builder)
3841
builder.RegisterType<RequestManager>()
3942
.As<IRequestManager>()
4043
.InstancePerLifetimeScope();
44+
45+
builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
46+
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
47+
4148
}
4249
}
4350
}

src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,11 @@ protected override void Load(ContainerBuilder builder)
2121

2222
// Register all the Command classes (they implement IAsyncRequestHandler) in assembly holding the Commands
2323
builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly)
24-
.As(o => o.GetInterfaces()
25-
.Where(i => i.IsClosedTypeOf(typeof(IAsyncRequestHandler<,>)))
26-
.Select(i => new KeyedService("IAsyncRequestHandler", i)));
24+
.AsClosedTypesOf(typeof(IAsyncRequestHandler<,>));
2725

2826
// Register all the event classes (they implement IAsyncNotificationHandler) in assembly holding the Commands
2927
builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly)
30-
.As(o => o.GetInterfaces()
31-
.Where(i => i.IsClosedTypeOf(typeof(IAsyncNotificationHandler<>)))
32-
.Select(i => new KeyedService("IAsyncNotificationHandler", i)))
33-
.AsImplementedInterfaces();
28+
.AsClosedTypesOf(typeof(IAsyncNotificationHandler<>));
3429

3530

3631
builder

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ItemGroup>
3535
<PackageReference Include="FluentValidation.AspNetCore" Version="7.0.3" />
3636
<PackageReference Include="FluentValidation.MVC6" Version="6.4.0" />
37-
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="2.0.0" />
37+
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="3.0.0" />
3838
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
3939
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
4040
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" />

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
6767
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
6868
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI
6969
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
70-
70+
7171
// Configure GracePeriodManager Hosted Service
7272
services.AddSingleton<IHostedService, GracePeriodManagerService>();
7373
services.Configure<GracePeriodManagerSettings>(Configuration);
7474

75+
services.AddTransient<IOrderingIntegrationEventService, OrderingIntegrationEventService>();
76+
7577
services.AddHealthChecks(checks =>
7678
{
7779
var minutes = 1;

0 commit comments

Comments
 (0)