From 4c843f24399c99a1e5791786bd02f2659278a470 Mon Sep 17 00:00:00 2001 From: Nico Lachmuth Date: Sat, 14 Dec 2024 17:26:45 +0100 Subject: [PATCH 1/2] aadded interface for rabbitmq eventbus --- .../Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs | 2 +- .../Abp/EventBus/RabbitMq/IRabbitMqDistributedEventBus.cs | 8 ++++++++ .../Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/IRabbitMqDistributedEventBus.cs diff --git a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs index 5d3db22726..92399b43b0 100644 --- a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs +++ b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/AbpEventBusRabbitMqModule.cs @@ -20,7 +20,7 @@ public class AbpEventBusRabbitMqModule : AbpModule { context .ServiceProvider - .GetRequiredService() + .GetRequiredService() .Initialize(); } } diff --git a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/IRabbitMqDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/IRabbitMqDistributedEventBus.cs new file mode 100644 index 0000000000..fd88a098a2 --- /dev/null +++ b/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(); +} 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 1c8012f529..a670c32a29 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 @@ -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(); } - 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( From d4a49455d1a5f91428adada5cf6173a561c2af30 Mon Sep 17 00:00:00 2001 From: Nico Lachmuth Date: Sat, 14 Dec 2024 17:55:35 +0100 Subject: [PATCH 2/2] fix ExposeService attribute --- .../Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a670c32a29..c84aa6d9e9 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 @@ -23,7 +23,7 @@ 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), typeof(IRabbitMqDistributedEventBus)] +[ExposeServices(typeof(IDistributedEventBus), typeof(RabbitMqDistributedEventBus), typeof(IRabbitMqDistributedEventBus))] public class RabbitMqDistributedEventBus : DistributedEventBusBase, IRabbitMqDistributedEventBus, ISingletonDependency { protected AbpRabbitMqEventBusOptions AbpRabbitMqEventBusOptions { get; }