From f719bda32f9b0469684d02e045d87eeabd2a833c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 28 Jun 2019 18:59:05 +0300 Subject: [PATCH] Use IServiceScopeFactory instead of IHybridServiceScopeFactory for event bus. --- .../Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs | 1 + .../Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs | 3 ++- .../Abp/EventBus/Distributed/LocalDistributedEventBus.cs | 9 ++++++--- .../Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs | 7 +++---- .../Volo/Abp/EventBus/IocEventHandlerFactory.cs | 4 ++-- .../Volo/Abp/EventBus/Local/LocalEventBus.cs | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs b/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs index 91678766f3..266c9c5d8e 100644 --- a/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs +++ b/framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs @@ -14,6 +14,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ protected ConcurrentDictionary JobQueues { get; } protected IServiceProvider ServiceProvider { get; } + protected BackgroundJobOptions Options { get; } public JobQueueManager( diff --git a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs index 67028207e5..ad8643ebae 100644 --- a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using RabbitMQ.Client; using RabbitMQ.Client.Events; @@ -36,7 +37,7 @@ namespace Volo.Abp.EventBus.RabbitMq IOptions options, IConnectionPool connectionPool, IRabbitMqSerializer serializer, - IHybridServiceScopeFactory serviceScopeFactory, + IServiceScopeFactory serviceScopeFactory, IOptions distributedEventBusOptions, IRabbitMqMessageConsumerFactory messageConsumerFactory) : base(serviceScopeFactory) diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs index ab23119642..75042c7f46 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus.cs @@ -1,6 +1,7 @@ using System; using System.Reflection; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.Collections; using Volo.Abp.DependencyInjection; @@ -10,15 +11,17 @@ namespace Volo.Abp.EventBus.Distributed { [Dependency(TryRegister = true)] [ExposeServices(typeof(IDistributedEventBus), typeof(LocalDistributedEventBus))] - public class LocalDistributedEventBus : IDistributedEventBus, ISingletonDependency + public class LocalDistributedEventBus : IDistributedEventBus, ITransientDependency { private readonly ILocalEventBus _localEventBus; - protected IHybridServiceScopeFactory ServiceScopeFactory { get; } + + protected IServiceScopeFactory ServiceScopeFactory { get; } + protected DistributedEventBusOptions DistributedEventBusOptions { get; } public LocalDistributedEventBus( ILocalEventBus localEventBus, - IHybridServiceScopeFactory serviceScopeFactory, + IServiceScopeFactory serviceScopeFactory, IOptions distributedEventBusOptions) { _localEventBus = localEventBus; diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs index 551b508a40..321aae6804 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Design; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Collections; -using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Reflection; @@ -15,9 +14,9 @@ namespace Volo.Abp.EventBus { public abstract class EventBusBase : IEventBus { - protected IHybridServiceScopeFactory ServiceScopeFactory { get; } + protected IServiceScopeFactory ServiceScopeFactory { get; } - protected EventBusBase(IHybridServiceScopeFactory serviceScopeFactory) + protected EventBusBase(IServiceScopeFactory serviceScopeFactory) { ServiceScopeFactory = serviceScopeFactory; } diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IocEventHandlerFactory.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IocEventHandlerFactory.cs index 2a028a521e..6a467281c6 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IocEventHandlerFactory.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IocEventHandlerFactory.cs @@ -14,9 +14,9 @@ namespace Volo.Abp.EventBus { public Type HandlerType { get; } - protected IHybridServiceScopeFactory ScopeFactory { get; } + protected IServiceScopeFactory ScopeFactory { get; } - public IocEventHandlerFactory(IHybridServiceScopeFactory scopeFactory, Type handlerType) + public IocEventHandlerFactory(IServiceScopeFactory scopeFactory, Type handlerType) { ScopeFactory = scopeFactory; HandlerType = handlerType; diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs index 18470a30fd..775e89a6fa 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs @@ -6,6 +6,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; using Volo.Abp.Threading; @@ -28,7 +29,7 @@ namespace Volo.Abp.EventBus.Local public LocalEventBus( IOptions options, - IHybridServiceScopeFactory serviceScopeFactory) + IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory) { Options = options.Value;