Browse Source

Rename RabbitMqDistributedEventBusOptions to RabbitMqEventBusOptions.

pull/751/head
Halil ibrahim Kalkan 8 years ago
parent
commit
10fa66936f
  1. 9
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/AbpEventBusRabbitMqModule.cs
  2. 21
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs
  3. 2
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqEventBusOptions.cs

9
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/AbpEventBusRabbitMqModule.cs

@ -1,6 +1,8 @@
using Volo.Abp.Modularity; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.RabbitMQ; using Volo.Abp.RabbitMQ;
//TODO: Rename Volo.Abp.EventBus.Distributed.RabbitMq namespace to Volo.Abp.EventBus.RabbitMq
namespace Volo.Abp.EventBus.Distributed.RabbitMq namespace Volo.Abp.EventBus.Distributed.RabbitMq
{ {
[DependsOn( [DependsOn(
@ -8,6 +10,11 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
typeof(AbpRabbitMqModule))] typeof(AbpRabbitMqModule))]
public class AbpEventBusRabbitMqModule : AbpModule public class AbpEventBusRabbitMqModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<RabbitMqEventBusOptions>(configuration.GetSection("RabbitMqEventBus"));
}
} }
} }

21
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBus.cs

@ -20,7 +20,7 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
[ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus))] [ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus))]
public class RabbitMqDistributedEventBus : EventBusBase, IDistributedEventBus, ISingletonDependency public class RabbitMqDistributedEventBus : EventBusBase, IDistributedEventBus, ISingletonDependency
{ {
protected RabbitMqDistributedEventBusOptions RabbitMqDistributedEventBusOptions { get; } protected RabbitMqEventBusOptions RabbitMqEventBusOptions { get; }
protected DistributedEventBusOptions DistributedEventBusOptions { get; } protected DistributedEventBusOptions DistributedEventBusOptions { get; }
protected IConnectionPool ConnectionPool { get; } protected IConnectionPool ConnectionPool { get; }
protected IRabbitMqSerializer Serializer { get; } protected IRabbitMqSerializer Serializer { get; }
@ -32,7 +32,7 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
protected IRabbitMqMessageConsumer Consumer { get; } protected IRabbitMqMessageConsumer Consumer { get; }
public RabbitMqDistributedEventBus( public RabbitMqDistributedEventBus(
IOptions<RabbitMqDistributedEventBusOptions> options, IOptions<RabbitMqEventBusOptions> options,
IConnectionPool connectionPool, IConnectionPool connectionPool,
IRabbitMqSerializer serializer, IRabbitMqSerializer serializer,
IHybridServiceScopeFactory serviceScopeFactory, IHybridServiceScopeFactory serviceScopeFactory,
@ -44,24 +44,24 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
Serializer = serializer; Serializer = serializer;
MessageConsumerFactory = messageConsumerFactory; MessageConsumerFactory = messageConsumerFactory;
DistributedEventBusOptions = distributedEventBusOptions.Value; DistributedEventBusOptions = distributedEventBusOptions.Value;
RabbitMqDistributedEventBusOptions = options.Value; RabbitMqEventBusOptions = options.Value;
HandlerFactories = new ConcurrentDictionary<Type, List<IEventHandlerFactory>>(); HandlerFactories = new ConcurrentDictionary<Type, List<IEventHandlerFactory>>();
EventTypes = new ConcurrentDictionary<string, Type>(); EventTypes = new ConcurrentDictionary<string, Type>();
Consumer = MessageConsumerFactory.Create( Consumer = MessageConsumerFactory.Create(
new ExchangeDeclareConfiguration( new ExchangeDeclareConfiguration(
RabbitMqDistributedEventBusOptions.ExchangeName, RabbitMqEventBusOptions.ExchangeName,
type: "direct", type: "direct",
durable: true durable: true
), ),
new QueueDeclareConfiguration( new QueueDeclareConfiguration(
RabbitMqDistributedEventBusOptions.ClientName, RabbitMqEventBusOptions.ClientName,
durable: true, durable: true,
exclusive: false, exclusive: false,
autoDelete: false autoDelete: false
), ),
RabbitMqDistributedEventBusOptions.ConnectionName RabbitMqEventBusOptions.ConnectionName
); );
Consumer.OnMessageReceived(ProcessEventAsync); Consumer.OnMessageReceived(ProcessEventAsync);
@ -96,8 +96,7 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
if (handlerFactories.Count == 1) //TODO: Multi-threading! if (handlerFactories.Count == 1) //TODO: Multi-threading!
{ {
var eventName = EventNameAttribute.GetNameOrDefault(eventType); Consumer.BindAsync(EventNameAttribute.GetNameOrDefault(eventType));
Consumer.BindAsync(eventName);
} }
return new EventHandlerFactoryUnregistrar(this, eventType, factory); return new EventHandlerFactoryUnregistrar(this, eventType, factory);
@ -162,10 +161,10 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
var eventName = EventNameAttribute.GetNameOrDefault(eventType); var eventName = EventNameAttribute.GetNameOrDefault(eventType);
var body = Serializer.Serialize(eventData); var body = Serializer.Serialize(eventData);
using (var channel = ConnectionPool.Get(RabbitMqDistributedEventBusOptions.ConnectionName).CreateModel()) using (var channel = ConnectionPool.Get(RabbitMqEventBusOptions.ConnectionName).CreateModel())
{ {
channel.ExchangeDeclare( channel.ExchangeDeclare(
RabbitMqDistributedEventBusOptions.ExchangeName, RabbitMqEventBusOptions.ExchangeName,
"direct", "direct",
durable: true durable: true
); );
@ -174,7 +173,7 @@ namespace Volo.Abp.EventBus.Distributed.RabbitMq
properties.DeliveryMode = RabbitMqConsts.DeliveryModes.Persistent; properties.DeliveryMode = RabbitMqConsts.DeliveryModes.Persistent;
channel.BasicPublish( channel.BasicPublish(
exchange: RabbitMqDistributedEventBusOptions.ExchangeName, exchange: RabbitMqEventBusOptions.ExchangeName,
routingKey: eventName, routingKey: eventName,
mandatory: true, mandatory: true,
basicProperties: properties, basicProperties: properties,

2
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqDistributedEventBusOptions.cs → framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/Distributed/RabbitMq/RabbitMqEventBusOptions.cs

@ -1,6 +1,6 @@
namespace Volo.Abp.EventBus.Distributed.RabbitMq namespace Volo.Abp.EventBus.Distributed.RabbitMq
{ {
public class RabbitMqDistributedEventBusOptions public class RabbitMqEventBusOptions
{ {
public string ConnectionName { get; set; } public string ConnectionName { get; set; }
Loading…
Cancel
Save