Browse Source

Merge pull request #21630 from tntwist/rabbit-mq-eventbus

added interface for rabbitmq eventbus
pull/21651/head
maliming 1 year ago
committed by GitHub
parent
commit
cc4ef1a3e0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs
  2. 8
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/IRabbitMqDistributedEventBus.cs
  3. 8
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs

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

@ -20,7 +20,7 @@ public class AbpEventBusRabbitMqModule : AbpModule
{
context
.ServiceProvider
.GetRequiredService<RabbitMqDistributedEventBus>()
.GetRequiredService<IRabbitMqDistributedEventBus>()
.Initialize();
}
}

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

@ -0,0 +1,8 @@
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.EventBus.RabbitMq;
public interface IRabbitMqDistributedEventBus : IDistributedEventBus
{
void Initialize();
}

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

@ -23,8 +23,8 @@ namespace Volo.Abp.EventBus.RabbitMq;
/* TODO: How to handle unsubscribe to unbind on RabbitMq (may not be possible for)
*/
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus))]
public class RabbitMqDistributedEventBus : DistributedEventBusBase, ISingletonDependency
[ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus), typeof(IRabbitMqDistributedEventBus))]
public class RabbitMqDistributedEventBus : DistributedEventBusBase, IRabbitMqDistributedEventBus, ISingletonDependency
{
protected AbpRabbitMqEventBusOptions AbpRabbitMqEventBusOptions { get; }
protected IConnectionPool ConnectionPool { get; }
@ -72,7 +72,7 @@ public class RabbitMqDistributedEventBus : DistributedEventBusBase, ISingletonDe
EventTypes = new ConcurrentDictionary<string, Type>();
}
public void Initialize()
public virtual void Initialize()
{
Consumer = MessageConsumerFactory.Create(
new ExchangeDeclareConfiguration(
@ -290,7 +290,7 @@ public class RabbitMqDistributedEventBus : DistributedEventBusBase, ISingletonDe
var eventName = EventNameAttribute.GetNameOrDefault(eventType);
var body = Serializer.Serialize(eventData);
return PublishAsync( eventName, body, headersArguments, eventId, correlationId);
return PublishAsync(eventName, body, headersArguments, eventId, correlationId);
}
protected virtual Task PublishAsync(

Loading…
Cancel
Save