From 0c45dccd54f9c70b6fb2008df81b22655a5f2d20 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 25 Jan 2022 14:17:09 +0800 Subject: [PATCH] Update Rebus --- .../Abp/EventBus/Rebus/RebusDistributedEventBus.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs index 81611e180a..a5cac31235 100644 --- a/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Rebus.Bus; using Rebus.Pipeline; +using Rebus.Transport; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Guids; @@ -227,9 +228,14 @@ public class RebusDistributedEventBus : DistributedEventBusBase, ISingletonDepen { var outgoingEventArray = outgoingEvents.ToArray(); - foreach (var outgoingEvent in outgoingEventArray) + using (var scope = new RebusTransactionScope()) { - await PublishFromOutboxAsync(outgoingEvent, outboxConfig); + foreach (var outgoingEvent in outgoingEventArray) + { + await PublishFromOutboxAsync(outgoingEvent, outboxConfig); + } + + await scope.CompleteAsync(); } return new MultipleOutgoingEventPublishResult(outgoingEventArray);