Fixed issue #291ordering.api fails after submitting orders

This commit is contained in:
Ramón Tomás 2017-08-26 22:55:24 +02:00
parent 01469da7d3
commit 8dc176add9
4 changed files with 13 additions and 9 deletions

View File

@ -1,9 +1,12 @@
using Autofac; using Autofac;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries; using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate; using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency; using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories; using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories;
using System.Reflection;
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules
{ {
@ -38,6 +41,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
builder.RegisterType<RequestManager>() builder.RegisterType<RequestManager>()
.As<IRequestManager>() .As<IRequestManager>()
.InstancePerLifetimeScope(); .InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
} }
} }
} }

View File

@ -21,16 +21,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
// Register all the Command classes (they implement IAsyncRequestHandler) in assembly holding the Commands // Register all the Command classes (they implement IAsyncRequestHandler) in assembly holding the Commands
builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly) builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly)
.As(o => o.GetInterfaces() .AsClosedTypesOf(typeof(IAsyncRequestHandler<,>));
.Where(i => i.IsClosedTypeOf(typeof(IAsyncRequestHandler<,>)))
.Select(i => new KeyedService("IAsyncRequestHandler", i)));
// Register all the event classes (they implement IAsyncNotificationHandler) in assembly holding the Commands // Register all the event classes (they implement IAsyncNotificationHandler) in assembly holding the Commands
builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly) builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly)
.As(o => o.GetInterfaces() .AsClosedTypesOf(typeof(IAsyncNotificationHandler<>));
.Where(i => i.IsClosedTypeOf(typeof(IAsyncNotificationHandler<>)))
.Select(i => new KeyedService("IAsyncNotificationHandler", i)))
.AsImplementedInterfaces();
builder builder

View File

@ -34,7 +34,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="7.0.3" /> <PackageReference Include="FluentValidation.AspNetCore" Version="7.0.3" />
<PackageReference Include="FluentValidation.MVC6" Version="6.4.0" /> <PackageReference Include="FluentValidation.MVC6" Version="6.4.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="2.0.0" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" />

View File

@ -67,11 +67,13 @@
options.Filters.Add(typeof(HttpGlobalExceptionFilter)); options.Filters.Add(typeof(HttpGlobalExceptionFilter));
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI }).AddControllersAsServices(); //Injecting Controllers themselves thru DI
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services //For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
// Configure GracePeriodManager Hosted Service // Configure GracePeriodManager Hosted Service
services.AddSingleton<IHostedService, GracePeriodManagerService>(); services.AddSingleton<IHostedService, GracePeriodManagerService>();
services.Configure<GracePeriodManagerSettings>(Configuration); services.Configure<GracePeriodManagerSettings>(Configuration);
services.AddTransient<IOrderingIntegrationEventService, OrderingIntegrationEventService>();
services.AddHealthChecks(checks => services.AddHealthChecks(checks =>
{ {
var minutes = 1; var minutes = 1;