diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs index dd5f7f5b4..13ae99afa 100644 --- a/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs +++ b/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs @@ -18,7 +18,7 @@ namespace EventBus.Tests public void After_One_Event_Subscription_Should_Contain_The_Event() { var manager = new InMemoryEventBusSubscriptionsManager(); - manager.AddSubscription(() => new TestIntegrationEventHandler()); + manager.AddSubscription(); Assert.True(manager.HasSubscriptionsForEvent()); } @@ -26,7 +26,7 @@ namespace EventBus.Tests public void After_All_Subscriptions_Are_Deleted_Event_Should_No_Longer_Exists() { var manager = new InMemoryEventBusSubscriptionsManager(); - manager.AddSubscription(() => new TestIntegrationEventHandler()); + manager.AddSubscription(); manager.RemoveSubscription(); Assert.False(manager.HasSubscriptionsForEvent()); } @@ -37,7 +37,7 @@ namespace EventBus.Tests bool raised = false; var manager = new InMemoryEventBusSubscriptionsManager(); manager.OnEventRemoved += (o, e) => raised = true; - manager.AddSubscription(() => new TestIntegrationEventHandler()); + manager.AddSubscription(); manager.RemoveSubscription(); Assert.True(raised); } @@ -46,8 +46,8 @@ namespace EventBus.Tests public void Get_Handlers_For_Event_Should_Return_All_Handlers() { var manager = new InMemoryEventBusSubscriptionsManager(); - manager.AddSubscription(() => new TestIntegrationEventHandler()); - manager.AddSubscription(() => new TestIntegrationOtherEventHandler()); + manager.AddSubscription(); + manager.AddSubscription(); var handlers = manager.GetHandlersForEvent(); Assert.Equal(2, handlers.Count()); } diff --git a/src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs b/src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs index 7dd91541b..21436d3cd 100644 --- a/src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs +++ b/src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs @@ -5,10 +5,10 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions { public interface IEventBus { - void Subscribe(Func handler) + void Subscribe() where T : IntegrationEvent where TH : IIntegrationEventHandler; - void SubscribeDynamic(string eventName, Func handler) + void SubscribeDynamic(string eventName) where TH : IDynamicIntegrationEventHandler; void UnsubscribeDynamic(string eventName) diff --git a/src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs b/src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs index d46292356..c83c505b1 100644 --- a/src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs +++ b/src/BuildingBlocks/EventBus/EventBus/IEventBusSubscriptionsManager.cs @@ -10,10 +10,10 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus { bool IsEmpty { get; } event EventHandler OnEventRemoved; - void AddDynamicSubscription(string eventName, Func handler) + void AddDynamicSubscription(string eventName) where TH : IDynamicIntegrationEventHandler; - void AddSubscription(Func handler) + void AddSubscription() where T : IntegrationEvent where TH : IIntegrationEventHandler; diff --git a/src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs b/src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs index e85ef7064..88be8cf96 100644 --- a/src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs +++ b/src/BuildingBlocks/EventBus/EventBus/InMemoryEventBusSubscriptionsManager.cs @@ -26,34 +26,41 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus public bool IsEmpty => !_handlers.Keys.Any(); public void Clear() => _handlers.Clear(); - public void AddDynamicSubscription(string eventName, Func handler) + public void AddDynamicSubscription(string eventName) where TH : IDynamicIntegrationEventHandler { - DoAddSubscription(handler, eventName, isDynamic: true); + DoAddSubscription(typeof(TH), eventName, isDynamic: true); } - public void AddSubscription(Func handler) + public void AddSubscription() where T : IntegrationEvent where TH : IIntegrationEventHandler { var eventName = GetEventKey(); - DoAddSubscription(handler, eventName, isDynamic: false); + DoAddSubscription(typeof(TH), eventName, isDynamic: false); _eventTypes.Add(typeof(T)); } - private void DoAddSubscription(Delegate handler, string eventName, bool isDynamic) + private void DoAddSubscription(Type handlerType, string eventName, bool isDynamic) { if (!HasSubscriptionsForEvent(eventName)) { _handlers.Add(eventName, new List()); } + + if (_handlers[eventName].Any(s => s.HandlerType == handlerType)) + { + throw new ArgumentException( + $"Handler Type {handlerType.Name} already registered for '{eventName}'", nameof(handlerType)); + } + if (isDynamic) { - _handlers[eventName].Add(SubscriptionInfo.Dynamic(handler)); + _handlers[eventName].Add(SubscriptionInfo.Dynamic(handlerType)); } else { - _handlers[eventName].Add(SubscriptionInfo.Typed(handler)); + _handlers[eventName].Add(SubscriptionInfo.Typed(handlerType)); } } @@ -115,7 +122,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus private SubscriptionInfo FindDynamicSubscriptionToRemove(string eventName) where TH : IDynamicIntegrationEventHandler { - return DoFindHandlerToRemove(eventName, typeof(TH)); + return DoFindSubscriptionToRemove(eventName, typeof(TH)); } @@ -124,25 +131,18 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus where TH : IIntegrationEventHandler { var eventName = GetEventKey(); - return DoFindHandlerToRemove(eventName, typeof(TH)); + return DoFindSubscriptionToRemove(eventName, typeof(TH)); } - private SubscriptionInfo DoFindHandlerToRemove(string eventName, Type handlerType) + private SubscriptionInfo DoFindSubscriptionToRemove(string eventName, Type handlerType) { if (!HasSubscriptionsForEvent(eventName)) { return null; } - foreach (var subscription in _handlers[eventName]) - { - var genericArgs = subscription.Factory.GetType().GetGenericArguments(); - if (genericArgs.SingleOrDefault() == handlerType) - { - return subscription; - } - } - return null; + return _handlers[eventName].SingleOrDefault(s => s.HandlerType == handlerType); + } public bool HasSubscriptionsForEvent() where T : IntegrationEvent diff --git a/src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs b/src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs index 33c0aec26..a20b3031c 100644 --- a/src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs +++ b/src/BuildingBlocks/EventBus/EventBus/SubscriptionInfo.cs @@ -7,21 +7,21 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus public class SubscriptionInfo { public bool IsDynamic { get; } - public Delegate Factory { get; } + public Type HandlerType{ get; } - private SubscriptionInfo(bool isDynamic, Delegate factory) + private SubscriptionInfo(bool isDynamic, Type handlerType) { IsDynamic = isDynamic; - Factory = factory; + HandlerType = handlerType; } - public static SubscriptionInfo Dynamic(Delegate factory) + public static SubscriptionInfo Dynamic(Type handlerType) { - return new SubscriptionInfo(true, factory); + return new SubscriptionInfo(true, handlerType); } - public static SubscriptionInfo Typed(Delegate factory) + public static SubscriptionInfo Typed(Type handlerType) { - return new SubscriptionInfo(false, factory); + return new SubscriptionInfo(false, handlerType); } } } diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs index 3d32073a3..07a130f22 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs @@ -1,4 +1,5 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; +using Autofac; +using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; using Microsoft.Extensions.Logging; @@ -26,17 +27,20 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ private readonly IRabbitMQPersistentConnection _persistentConnection; private readonly ILogger _logger; private readonly IEventBusSubscriptionsManager _subsManager; - + private readonly ILifetimeScope _autofac; + private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus"; private IModel _consumerChannel; private string _queueName; - public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger logger, IEventBusSubscriptionsManager subsManager) + public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger logger, + ILifetimeScope autofac, IEventBusSubscriptionsManager subsManager) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _consumerChannel = CreateConsumerChannel(); + _autofac = autofac; _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; } @@ -97,20 +101,20 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ } } - public void SubscribeDynamic(string eventName, Func handler) - where TH: IDynamicIntegrationEventHandler + public void SubscribeDynamic(string eventName) + where TH : IDynamicIntegrationEventHandler { DoInternalSubscription(eventName); - _subsManager.AddDynamicSubscription(eventName,handler); + _subsManager.AddDynamicSubscription(eventName); } - public void Subscribe(Func handler) + public void Subscribe() where T : IntegrationEvent where TH : IIntegrationEventHandler { var eventName = _subsManager.GetEventKey(); DoInternalSubscription(eventName); - _subsManager.AddSubscription(handler); + _subsManager.AddSubscription(); } private void DoInternalSubscription(string eventName) @@ -140,7 +144,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ } public void UnsubscribeDynamic(string eventName) - where TH: IDynamicIntegrationEventHandler + where TH : IDynamicIntegrationEventHandler { _subsManager.RemoveDynamicSubscription(eventName); } @@ -195,25 +199,28 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ private async Task ProcessEvent(string eventName, string message) { + if (_subsManager.HasSubscriptionsForEvent(eventName)) { - var subscriptions = _subsManager.GetHandlersForEvent(eventName); - - foreach (var subscription in subscriptions) + using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME)) { - if (subscription.IsDynamic) - { - var handler = subscription.Factory.DynamicInvoke() as IDynamicIntegrationEventHandler; - dynamic eventData = JObject.Parse(message); - await handler.Handle(eventData); - } - else + var subscriptions = _subsManager.GetHandlersForEvent(eventName); + foreach (var subscription in subscriptions) { - var eventType = _subsManager.GetEventTypeByName(eventName); - var integrationEvent = JsonConvert.DeserializeObject(message, eventType); - var handler = subscription.Factory.DynamicInvoke(); - var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType); - await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent }); + if (subscription.IsDynamic) + { + var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler; + dynamic eventData = JObject.Parse(message); + await handler.Handle(eventData); + } + else + { + var eventType = _subsManager.GetEventTypeByName(eventName); + var integrationEvent = JsonConvert.DeserializeObject(message, eventType); + var handler = scope.ResolveOptional(subscription.HandlerType); + var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType); + await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent }); + } } } } diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj index 023a5d5ec..fd2b44b30 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index b3ba97b10..de78d78b6 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -22,6 +22,7 @@ + diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index bf63b2c29..2c1e70645 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -23,6 +23,8 @@ using System.Threading.Tasks; using System; using Microsoft.eShopOnContainers.Services.Basket.API.Services; using Microsoft.AspNetCore.Http; +using Autofac; +using Autofac.Extensions.DependencyInjection; namespace Microsoft.eShopOnContainers.Services.Basket.API { @@ -41,7 +43,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddHealthChecks(checks => @@ -112,6 +114,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API services.AddTransient(); services.AddTransient(); RegisterServiceBus(services); + + var container = new ContainerBuilder(); + container.Populate(services); + return new AutofacServiceProvider(container.Build()); } private void RegisterServiceBus(IServiceCollection services) @@ -167,11 +173,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API var eventBus = app.ApplicationServices.GetRequiredService(); - eventBus.Subscribe - (() => app.ApplicationServices.GetRequiredService()); - - eventBus.Subscribe - (() => app.ApplicationServices.GetRequiredService()); + eventBus.Subscribe(); + eventBus.Subscribe(); } } } diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 4306d6922..3c2686278 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -29,6 +29,7 @@ + diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 9eb195674..509048d4c 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -1,5 +1,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API { + using Autofac; + using Autofac.Extensions.DependencyInjection; using global::Catalog.API.Infrastructure.Filters; using global::Catalog.API.IntegrationEvents; using Microsoft.AspNetCore.Builder; @@ -44,7 +46,7 @@ Configuration = builder.Build(); } - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. @@ -118,6 +120,10 @@ services.AddSingleton(); services.AddSingleton(); + + var container = new ContainerBuilder(); + container.Populate(services); + return new AutofacServiceProvider(container.Build()); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index e99a6efa9..e88054a12 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index b47f0535d..b9458c078 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -19,6 +19,8 @@ using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.HealthChecks; using Identity.API.Certificate; +using Autofac.Extensions.DependencyInjection; +using Autofac; namespace eShopOnContainers.Identity { @@ -44,7 +46,7 @@ namespace eShopOnContainers.Identity public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. @@ -87,7 +89,11 @@ namespace eShopOnContainers.Identity .AddInMemoryIdentityResources(Config.GetResources()) .AddInMemoryClients(Config.GetClients(clientUrls)) .AddAspNetIdentity() - .Services.AddTransient(); + .Services.AddTransient(); + + var container = new ContainerBuilder(); + container.Populate(services); + return new AutofacServiceProvider(container.Build()); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs index 2b8902652..831a1ec1e 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs @@ -7,6 +7,7 @@ using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; using System; using System.Data.Common; +using System.Diagnostics; using System.Threading.Tasks; namespace Ordering.API.Application.IntegrationEvents diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 315777e3b..af3894096 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -156,14 +156,13 @@ app.UseFailingMiddleware(); ConfigureAuth(app); - ConfigureEventBus(app); - app.UseMvcWithDefaultRoute(); app.UseSwagger() .UseSwaggerUi(); OrderingContextSeed.SeedAsync(app).Wait(); + ConfigureEventBus(app); var integrationEventLogContext = new IntegrationEventLogContext( new DbContextOptionsBuilder() diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs index 7519a7de3..341d33c6f 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs @@ -38,7 +38,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O private int? _paymentMethodId; - protected Order() { } + protected Order() { _orderItems = new List(); } public Order(Address address, int cardTypeId, string cardNumber, string cardSecurityNumber, string cardHolderName, DateTime cardExpiration, int? buyerId = null, int? paymentMethodId = null) diff --git a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs index 18d66534b..a160558ef 100644 --- a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs +++ b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs @@ -36,6 +36,9 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure public OrderingContext(DbContextOptions options, IMediator mediator) : base(options) { _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); + + + System.Diagnostics.Debug.WriteLine("OrderingContext::ctor ->" + this.GetHashCode()); } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/src/Services/Payment/Payment.API/Payment.API.csproj b/src/Services/Payment/Payment.API/Payment.API.csproj index 6176c30fc..147cd2e3c 100644 --- a/src/Services/Payment/Payment.API/Payment.API.csproj +++ b/src/Services/Payment/Payment.API/Payment.API.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Services/Payment/Payment.API/Startup.cs b/src/Services/Payment/Payment.API/Startup.cs index 1e65fef5f..c5160a81d 100644 --- a/src/Services/Payment/Payment.API/Startup.cs +++ b/src/Services/Payment/Payment.API/Startup.cs @@ -1,8 +1,11 @@ -using Microsoft.AspNetCore.Builder; +using Autofac; +using Autofac.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using System; namespace Payment.API { @@ -21,7 +24,7 @@ namespace Payment.API public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); @@ -38,6 +41,10 @@ namespace Payment.API TermsOfService = "Terms Of Service" }); }); + + var container = new ContainerBuilder(); + container.Populate(services); + return new AutofacServiceProvider(container.Build()); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Services/SagaManager/SagaManager/Program.cs b/src/Services/SagaManager/SagaManager/Program.cs index 06fdec6ba..7de0704ea 100644 --- a/src/Services/SagaManager/SagaManager/Program.cs +++ b/src/Services/SagaManager/SagaManager/Program.cs @@ -16,7 +16,8 @@ namespace SagaManager using Microsoft.Extensions.Options; using RabbitMQ.Client; using Services; - + using Autofac.Extensions.DependencyInjection; + using Autofac; public class Program { @@ -76,6 +77,10 @@ namespace SagaManager RegisterServiceBus(services); + var container = new ContainerBuilder(); + container.Populate(services); + return new AutofacServiceProvider(container.Build()); + return services.BuildServiceProvider(); } diff --git a/src/Services/SagaManager/SagaManager/SagaManager.csproj b/src/Services/SagaManager/SagaManager/SagaManager.csproj index ed76ff6d8..f5eafa793 100644 --- a/src/Services/SagaManager/SagaManager/SagaManager.csproj +++ b/src/Services/SagaManager/SagaManager/SagaManager.csproj @@ -6,6 +6,7 @@ +