Browse Source

Initialize the RabbitMqDistributedEventBus.

pull/870/head
Halil ibrahim Kalkan 8 years ago
parent
commit
a7708e3dc9
  1. 8
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs
  2. 13
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs

8
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs

@ -15,5 +15,13 @@ namespace Volo.Abp.EventBus.RabbitMq
Configure<RabbitMqEventBusOptions>(configuration.GetSection("RabbitMQ:EventBus"));
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
context
.ServiceProvider
.GetRequiredService<RabbitMqDistributedEventBus>()
.Initialize();
}
}
}

13
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.EventBus.RabbitMq
protected ConcurrentDictionary<Type, List<IEventHandlerFactory>> HandlerFactories { get; }
protected ConcurrentDictionary<string, Type> EventTypes { get; }
protected IRabbitMqMessageConsumerFactory MessageConsumerFactory { get; }
protected IRabbitMqMessageConsumer Consumer { get; }
protected IRabbitMqMessageConsumer Consumer { get; private set; }
public RabbitMqDistributedEventBus(
IOptions<RabbitMqEventBusOptions> options,
@ -50,18 +50,23 @@ namespace Volo.Abp.EventBus.RabbitMq
HandlerFactories = new ConcurrentDictionary<Type, List<IEventHandlerFactory>>();
EventTypes = new ConcurrentDictionary<string, Type>();
Initialize();
}
public void Initialize()
{
Consumer = MessageConsumerFactory.Create(
new ExchangeDeclareConfiguration(
RabbitMqEventBusOptions.ExchangeName,
RabbitMqEventBusOptions.ExchangeName,
type: "direct",
durable: true
),
),
new QueueDeclareConfiguration(
RabbitMqEventBusOptions.ClientName,
durable: true,
exclusive: false,
autoDelete: false
),
),
RabbitMqEventBusOptions.ConnectionName
);

Loading…
Cancel
Save