Remove autofac from the solution
This commit is contained in:
parent
3af7133157
commit
89c2291812
@ -5,7 +5,8 @@
|
||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.EventBus</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
||||
{
|
||||
public static class EventBusServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddEventHandlers(this IServiceCollection services, System.Reflection.Assembly assembly)
|
||||
{
|
||||
foreach (var typeInfo in assembly.GetTypes()
|
||||
.Where(t => typeof(IIntegrationEventHandler).IsAssignableFrom(t)
|
||||
&& t.IsClass
|
||||
&& !t.IsAbstract
|
||||
&& !t.ContainsGenericParameters
|
||||
&& t.GetConstructors(BindingFlags.Public | BindingFlags.Instance)?.Length != 0))
|
||||
{
|
||||
services.AddScoped(typeInfo);
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,26 +3,24 @@
|
||||
public class EventBusRabbitMQ : IEventBus, IDisposable
|
||||
{
|
||||
const string BROKER_NAME = "eshop_event_bus";
|
||||
const string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
||||
|
||||
private readonly IRabbitMQPersistentConnection _persistentConnection;
|
||||
private readonly ILogger<EventBusRabbitMQ> _logger;
|
||||
private readonly IEventBusSubscriptionsManager _subsManager;
|
||||
private readonly ILifetimeScope _autofac;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly int _retryCount;
|
||||
|
||||
private IModel _consumerChannel;
|
||||
private string _queueName;
|
||||
|
||||
public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger<EventBusRabbitMQ> logger,
|
||||
ILifetimeScope autofac, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5)
|
||||
IServiceScopeFactory serviceScopeFactory, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5)
|
||||
{
|
||||
_persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
|
||||
_queueName = queueName;
|
||||
_consumerChannel = CreateConsumerChannel();
|
||||
_autofac = autofac;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_retryCount = retryCount;
|
||||
_subsManager.OnEventRemoved += SubsManager_OnEventRemoved;
|
||||
}
|
||||
@ -244,14 +242,14 @@ public class EventBusRabbitMQ : IEventBus, IDisposable
|
||||
|
||||
if (_subsManager.HasSubscriptionsForEvent(eventName))
|
||||
{
|
||||
using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME))
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var subscriptions = _subsManager.GetHandlersForEvent(eventName);
|
||||
foreach (var subscription in subscriptions)
|
||||
{
|
||||
if (subscription.IsDynamic)
|
||||
{
|
||||
var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;
|
||||
var handler = scope.ServiceProvider.GetService(subscription.HandlerType) as IDynamicIntegrationEventHandler;
|
||||
if (handler == null) continue;
|
||||
using dynamic eventData = JsonDocument.Parse(message);
|
||||
await Task.Yield();
|
||||
@ -259,7 +257,7 @@ public class EventBusRabbitMQ : IEventBus, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
var handler = scope.ResolveOptional(subscription.HandlerType);
|
||||
var handler = scope.ServiceProvider.GetService(subscription.HandlerType);
|
||||
if (handler == null) continue;
|
||||
var eventType = _subsManager.GetEventTypeByName(eventName);
|
||||
var integrationEvent = JsonSerializer.Deserialize(message, eventType, new JsonSerializerOptions() { PropertyNameCaseInsensitive= true});
|
||||
|
@ -6,7 +6,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Polly" Version="7.2.1" />
|
||||
|
@ -7,7 +7,7 @@ global using RabbitMQ.Client.Exceptions;
|
||||
global using System;
|
||||
global using System.IO;
|
||||
global using System.Net.Sockets;
|
||||
global using Autofac;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||
|
@ -5,21 +5,20 @@ public class EventBusServiceBus : IEventBus, IDisposable
|
||||
private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection;
|
||||
private readonly ILogger<EventBusServiceBus> _logger;
|
||||
private readonly IEventBusSubscriptionsManager _subsManager;
|
||||
private readonly ILifetimeScope _autofac;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly string _topicName = "eshop_event_bus";
|
||||
private readonly string _subscriptionName;
|
||||
private ServiceBusSender _sender;
|
||||
private ServiceBusProcessor _processor;
|
||||
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
||||
private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent";
|
||||
|
||||
public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection,
|
||||
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, ILifetimeScope autofac, string subscriptionClientName)
|
||||
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, IServiceScopeFactory serviceScopeFactory, string subscriptionClientName)
|
||||
{
|
||||
_serviceBusPersisterConnection = serviceBusPersisterConnection;
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
|
||||
_autofac = autofac;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_subscriptionName = subscriptionClientName;
|
||||
_sender = _serviceBusPersisterConnection.TopicClient.CreateSender(_topicName);
|
||||
ServiceBusProcessorOptions options = new ServiceBusProcessorOptions { MaxConcurrentCalls = 10, AutoCompleteMessages = false };
|
||||
@ -155,14 +154,14 @@ public class EventBusServiceBus : IEventBus, IDisposable
|
||||
var processed = false;
|
||||
if (_subsManager.HasSubscriptionsForEvent(eventName))
|
||||
{
|
||||
using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME))
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var subscriptions = _subsManager.GetHandlersForEvent(eventName);
|
||||
foreach (var subscription in subscriptions)
|
||||
{
|
||||
if (subscription.IsDynamic)
|
||||
{
|
||||
var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;
|
||||
var handler = scope.ServiceProvider.GetService(subscription.HandlerType) as IDynamicIntegrationEventHandler;
|
||||
if (handler == null) continue;
|
||||
|
||||
using dynamic eventData = JsonDocument.Parse(message);
|
||||
@ -170,7 +169,7 @@ public class EventBusServiceBus : IEventBus, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
var handler = scope.ResolveOptional(subscription.HandlerType);
|
||||
var handler = scope.ServiceProvider.GetService(subscription.HandlerType);
|
||||
if (handler == null) continue;
|
||||
var eventType = _subsManager.GetEventTypeByName(eventName);
|
||||
var integrationEvent = JsonSerializer.Deserialize(message, eventType);
|
||||
|
@ -6,7 +6,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.1" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
|
@ -6,7 +6,7 @@ global using System.Linq;
|
||||
global using System.Text.Json.Serialization;
|
||||
global using System.Threading.Tasks;
|
||||
global using System;
|
||||
global using Autofac;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using System.Text;
|
||||
|
@ -20,7 +20,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="5.0.2" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
|
||||
|
@ -1,5 +1,3 @@
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Azure.Core;
|
||||
global using Azure.Identity;
|
||||
global using Basket.API.Infrastructure.ActionResults;
|
||||
|
@ -9,7 +9,7 @@ public class Startup
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public virtual void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddGrpc(options =>
|
||||
{
|
||||
@ -135,11 +135,6 @@ public class Startup
|
||||
services.AddTransient<IIdentityService, IdentityService>();
|
||||
|
||||
services.AddOptions();
|
||||
|
||||
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.
|
||||
@ -240,13 +235,13 @@ public class Startup
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -255,7 +250,7 @@ public class Startup
|
||||
{
|
||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -265,7 +260,7 @@ public class Startup
|
||||
retryCount = int.Parse(Configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,14 @@ namespace Basket.FunctionalTests.Base
|
||||
{
|
||||
}
|
||||
|
||||
public override IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Added to avoid the Authorize data annotation in test environment.
|
||||
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
|
||||
services.Configure<RouteOptions>(Configuration);
|
||||
return base.ConfigureServices(services);
|
||||
base.ConfigureServices(services);
|
||||
}
|
||||
|
||||
|
||||
protected override void ConfigureAuth(IApplicationBuilder app)
|
||||
{
|
||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||
|
@ -1,7 +1,5 @@
|
||||
global using Azure.Core;
|
||||
global using Azure.Identity;
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Microsoft.eShopOnContainers.Services.Catalog.API.Extensions;
|
||||
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.ActionResults;
|
||||
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Exceptions;
|
||||
|
@ -9,7 +9,7 @@ public class Startup
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddAppInsight(Configuration)
|
||||
.AddGrpc().Services
|
||||
@ -20,11 +20,6 @@ public class Startup
|
||||
.AddEventBus(Configuration)
|
||||
.AddSwagger(Configuration)
|
||||
.AddCustomHealthCheck(Configuration);
|
||||
|
||||
var container = new ContainerBuilder();
|
||||
container.Populate(services);
|
||||
|
||||
return new AutofacServiceProvider(container.Build());
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||
@ -294,13 +289,13 @@ public static class CustomExtensionMethods
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
|
||||
}
|
||||
@ -310,7 +305,7 @@ public static class CustomExtensionMethods
|
||||
{
|
||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -320,7 +315,7 @@ public static class CustomExtensionMethods
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
global using Microsoft.eShopOnContainers.Services.Identity.API.Extensions;
|
||||
global using System.IO.Compression;
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Azure.Core;
|
||||
global using Azure.Identity;
|
||||
global using HealthChecks.UI.Client;
|
||||
|
@ -17,7 +17,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.4" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework.Storage" Version="3.1.4" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="3.1.4" />
|
||||
|
@ -12,7 +12,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
RegisterAppInsights(services);
|
||||
|
||||
@ -88,11 +88,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
services.AddControllers();
|
||||
services.AddControllersWithViews();
|
||||
services.AddRazorPages();
|
||||
|
||||
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.
|
||||
|
@ -1,7 +1,5 @@
|
||||
global using ApiModels = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;
|
||||
global using AppCommand = Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Azure.Core;
|
||||
global using Azure.Identity;
|
||||
global using Dapper;
|
||||
@ -36,7 +34,6 @@ global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Comma
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStockConfirmed;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;
|
||||
|
@ -1,38 +0,0 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||
|
||||
public class ApplicationModule
|
||||
: Autofac.Module
|
||||
{
|
||||
|
||||
public string QueriesConnectionString { get; }
|
||||
|
||||
public ApplicationModule(string qconstr)
|
||||
{
|
||||
QueriesConnectionString = qconstr;
|
||||
|
||||
}
|
||||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
|
||||
builder.Register(c => new OrderQueries(QueriesConnectionString))
|
||||
.As<IOrderQueries>()
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.RegisterType<BuyerRepository>()
|
||||
.As<IBuyerRepository>()
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.RegisterType<OrderRepository>()
|
||||
.As<IOrderRepository>()
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.RegisterType<RequestManager>()
|
||||
.As<IRequestManager>()
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
|
||||
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
|
||||
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||
|
||||
public class MediatorModule : Autofac.Module
|
||||
{
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly)
|
||||
.AsImplementedInterfaces();
|
||||
|
||||
// Register all the Command classes (they implement IRequestHandler) in assembly holding the Commands
|
||||
builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly)
|
||||
.AsClosedTypesOf(typeof(IRequestHandler<,>));
|
||||
|
||||
// Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events
|
||||
builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly)
|
||||
.AsClosedTypesOf(typeof(INotificationHandler<>));
|
||||
|
||||
// Register the Command's Validators (Validators based on FluentValidation library)
|
||||
builder
|
||||
.RegisterAssemblyTypes(typeof(CreateOrderCommandValidator).GetTypeInfo().Assembly)
|
||||
.Where(t => t.IsClosedTypeOf(typeof(IValidator<>)))
|
||||
.AsImplementedInterfaces();
|
||||
|
||||
|
||||
builder.Register<ServiceFactory>(context =>
|
||||
{
|
||||
var componentContext = context.Resolve<IComponentContext>();
|
||||
return t => { object o; return componentContext.TryResolve(t, out o) ? o : null; };
|
||||
});
|
||||
|
||||
builder.RegisterGeneric(typeof(LoggingBehavior<,>)).As(typeof(IPipelineBehavior<,>));
|
||||
builder.RegisterGeneric(typeof(ValidatorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
|
||||
builder.RegisterGeneric(typeof(TransactionBehaviour<,>)).As(typeof(IPipelineBehavior<,>));
|
||||
|
||||
}
|
||||
}
|
@ -40,7 +40,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||
|
@ -9,7 +9,7 @@ public class Startup
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public virtual void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddGrpc(options =>
|
||||
@ -25,16 +25,13 @@ public class Startup
|
||||
.AddCustomIntegrations(Configuration)
|
||||
.AddCustomConfiguration(Configuration)
|
||||
.AddEventBus(Configuration)
|
||||
.AddCustomAuthentication(Configuration);
|
||||
//configure autofac
|
||||
|
||||
var container = new ContainerBuilder();
|
||||
container.Populate(services);
|
||||
|
||||
container.RegisterModule(new MediatorModule());
|
||||
container.RegisterModule(new ApplicationModule(Configuration["ConnectionString"]));
|
||||
|
||||
return new AutofacServiceProvider(container.Build());
|
||||
.AddCustomAuthentication(Configuration)
|
||||
.AddScoped<IOrderQueries>(sp => new OrderQueries(Configuration["ConnectionString"]))
|
||||
.AddScoped<IBuyerRepository, BuyerRepository>()
|
||||
.AddScoped<IOrderRepository, OrderRepository>()
|
||||
.AddScoped<IRequestManager, RequestManager>()
|
||||
.AddEventHandlers(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
|
||||
.AddMediatR(Assembly.GetExecutingAssembly());
|
||||
}
|
||||
|
||||
|
||||
@ -332,13 +329,13 @@ static class CustomExtensionsMethods
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -347,7 +344,7 @@ static class CustomExtensionsMethods
|
||||
{
|
||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -357,7 +354,7 @@ static class CustomExtensionsMethods
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Autofac;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
@ -61,12 +60,12 @@ namespace Ordering.BackgroundTasks.Extensions
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -104,7 +103,7 @@ namespace Ordering.BackgroundTasks.Extensions
|
||||
services.AddSingleton<IEventBus, EventBusRabbitMQ>(sp =>
|
||||
{
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -115,7 +114,7 @@ namespace Ordering.BackgroundTasks.Extensions
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
|
||||
|
@ -1,4 +1,3 @@
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@ -19,7 +18,6 @@ namespace Ordering.BackgroundTasks
|
||||
|
||||
public static IHost CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
||||
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
|
||||
.ConfigureAppConfiguration((host, builder) =>
|
||||
{
|
||||
|
@ -6,12 +6,12 @@ public class OrderingTestsStartup : Startup
|
||||
{
|
||||
}
|
||||
|
||||
public override IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Added to avoid the Authorize data annotation in test environment.
|
||||
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
|
||||
services.Configure<RouteOptions>(Configuration);
|
||||
return base.ConfigureServices(services);
|
||||
base.ConfigureServices(services);
|
||||
}
|
||||
protected override void ConfigureAuth(IApplicationBuilder app)
|
||||
{
|
||||
|
@ -1,20 +0,0 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules;
|
||||
|
||||
public class ApplicationModule
|
||||
: Autofac.Module
|
||||
{
|
||||
|
||||
public string QueriesConnectionString { get; }
|
||||
|
||||
public ApplicationModule()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
|
||||
builder.RegisterAssemblyTypes(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly)
|
||||
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using HealthChecks.UI.Client;
|
||||
global using HealthChecks.UI.Client;
|
||||
global using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
global using Microsoft.AspNetCore.Authorization;
|
||||
global using Microsoft.AspNetCore.Builder;
|
||||
@ -20,7 +18,6 @@ global using Microsoft.Extensions.Configuration;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events;
|
||||
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents;
|
||||
|
@ -15,7 +15,6 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="2.0.2-beta2" />
|
||||
|
@ -11,7 +11,7 @@ public class Startup
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddCustomHealthCheck(Configuration)
|
||||
@ -86,12 +86,7 @@ public class Startup
|
||||
|
||||
services.AddOptions();
|
||||
|
||||
//configure autofac
|
||||
var container = new ContainerBuilder();
|
||||
container.RegisterModule(new ApplicationModule());
|
||||
container.Populate(services);
|
||||
|
||||
return new AutofacServiceProvider(container.Build());
|
||||
services.AddEventHandlers(typeof(OrderStatusChangedToAwaitingValidationIntegrationEvent).GetTypeInfo().Assembly);
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@ -185,13 +180,13 @@ public class Startup
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -200,7 +195,7 @@ public class Startup
|
||||
{
|
||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -210,7 +205,7 @@ public class Startup
|
||||
retryCount = int.Parse(Configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Azure.Core;
|
||||
global using Azure.Core;
|
||||
global using Azure.Identity;
|
||||
global using HealthChecks.UI.Client;
|
||||
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
|
@ -12,8 +12,7 @@
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
|
||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||
|
@ -10,7 +10,7 @@ public class Startup
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCustomHealthCheck(Configuration);
|
||||
services.Configure<PaymentSettings>(Configuration);
|
||||
@ -59,10 +59,6 @@ public class Startup
|
||||
}
|
||||
|
||||
RegisterEventBus(services);
|
||||
|
||||
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.
|
||||
@ -107,13 +103,13 @@ public class Startup
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -122,7 +118,7 @@ public class Startup
|
||||
{
|
||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -132,7 +128,7 @@ public class Startup
|
||||
retryCount = int.Parse(Configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
global using Autofac.Extensions.DependencyInjection;
|
||||
global using Autofac;
|
||||
global using Devspaces.Support;
|
||||
global using Devspaces.Support;
|
||||
global using HealthChecks.UI.Client;
|
||||
global using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
global using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -9,7 +9,7 @@ public class Startup
|
||||
}
|
||||
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddAppInsight(Configuration)
|
||||
@ -27,10 +27,6 @@ public class Startup
|
||||
.AddTransient<IGrantUrlTesterService, GrantUrlTesterService>()
|
||||
.AddTransient<IWebhooksRetriever, WebhooksRetriever>()
|
||||
.AddTransient<IWebhooksSender, WebhooksSender>();
|
||||
|
||||
var container = new ContainerBuilder();
|
||||
container.Populate(services);
|
||||
return new AutofacServiceProvider(container.Build());
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
@ -175,13 +171,13 @@ static class CustomExtensionMethods
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||
eventBusSubcriptionsManager, serviceScopeFactory, subscriptionName);
|
||||
});
|
||||
|
||||
}
|
||||
@ -191,7 +187,7 @@ static class CustomExtensionMethods
|
||||
{
|
||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var serviceScopeFactory = sp.GetRequiredService<IServiceScopeFactory>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
@ -201,7 +197,7 @@ static class CustomExtensionMethods
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, serviceScopeFactory, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||
|
@ -36,7 +36,7 @@ public class OrderingService : IOrderingService
|
||||
var uri = API.Order.GetAllMyOrders(_remoteServiceBaseUrl);
|
||||
|
||||
var responseString = await _httpClient.GetStringAsync(uri);
|
||||
|
||||
|
||||
var response = JsonSerializer.Deserialize<List<Order>>(responseString, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
|
@ -20,7 +20,7 @@ services:
|
||||
ports:
|
||||
- "5433:1433"
|
||||
volumes:
|
||||
- eshop-sqldata:/var/opt/mssql
|
||||
- eshop-sqldata:/var/opt/mssql/data
|
||||
|
||||
nosqldata:
|
||||
ports:
|
||||
|
Loading…
x
Reference in New Issue
Block a user