diff --git a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventHandlerStep.cs b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventHandlerStep.cs index c0c655b596..7f99d03f56 100644 --- a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventHandlerStep.cs +++ b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventHandlerStep.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Rebus.Messages; @@ -14,9 +15,12 @@ public class AbpRebusEventHandlerStep : IIncomingStep var message = context.Load(); var handlerInvokers = context.Load().ToList(); - handlerInvokers.RemoveAll(x => x.Handler.GetType() == typeof(RebusDistributedEventHandlerAdapter)); - context.Save(new HandlerInvokers(message, handlerInvokers)); - + if (handlerInvokers.All(x => x.Handler is IRebusDistributedEventHandlerAdapter)) + { + handlerInvokers = new List {handlerInvokers.Last()}; + context.Save(new HandlerInvokers(message, handlerInvokers)); + } + return next(); } } diff --git a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/IRebusDistributedEventHandlerAdapter.cs b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/IRebusDistributedEventHandlerAdapter.cs new file mode 100644 index 0000000000..b756cc844d --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/IRebusDistributedEventHandlerAdapter.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.EventBus.Rebus; + +public interface IRebusDistributedEventHandlerAdapter +{ + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventHandlerAdapter.cs b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventHandlerAdapter.cs index 1735a5ce95..7f9343ecdf 100644 --- a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventHandlerAdapter.cs +++ b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventHandlerAdapter.cs @@ -3,7 +3,7 @@ using Rebus.Handlers; namespace Volo.Abp.EventBus.Rebus; -public class RebusDistributedEventHandlerAdapter : IHandleMessages +public class RebusDistributedEventHandlerAdapter : IHandleMessages , IRebusDistributedEventHandlerAdapter { protected RebusDistributedEventBus RebusDistributedEventBus { get; }