From 90c828c83a77ea731c62806852511353f1bb693d Mon Sep 17 00:00:00 2001 From: gdlcf88 Date: Tue, 31 May 2022 02:31:58 +0800 Subject: [PATCH 1/2] Make the Azure bus publishes many from outbox with MessageId --- .../Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs index 86500cf434..09faf1151e 100644 --- a/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs @@ -108,9 +108,14 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen foreach (var outgoingEvent in outgoingEventArray) { - if (!messageBatch.TryAddMessage(new ServiceBusMessage(outgoingEvent.EventData) { Subject = outgoingEvent.EventName })) + var message = new ServiceBusMessage(outgoingEvent.EventData) { + MessageId = outgoingEvent.Id.ToString(), Subject = outgoingEvent.EventName + }; + + if (!messageBatch.TryAddMessage(message)) { - throw new AbpException("The message is too large to fit in the batch. Set AbpEventBusBoxesOptions.OutboxWaitingEventMaxCount to reduce the number"); + throw new AbpException( + "The message is too large to fit in the batch. Set AbpEventBusBoxesOptions.OutboxWaitingEventMaxCount to reduce the number"); } } From 706d05e8889b6d0bb2155b54287c19194264f50e Mon Sep 17 00:00:00 2001 From: gdlcf88 Date: Fri, 3 Jun 2022 13:04:48 +0800 Subject: [PATCH 2/2] Set MessageId only if ServiceBusMessage doesn't have one --- .../Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs index 09faf1151e..78e26e7c32 100644 --- a/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs @@ -108,9 +108,12 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen foreach (var outgoingEvent in outgoingEventArray) { - var message = new ServiceBusMessage(outgoingEvent.EventData) { - MessageId = outgoingEvent.Id.ToString(), Subject = outgoingEvent.EventName - }; + var message = new ServiceBusMessage(outgoingEvent.EventData) { Subject = outgoingEvent.EventName }; + + if (message.MessageId.IsNullOrWhiteSpace()) + { + message.MessageId = outgoingEvent.Id.ToString(); + } if (!messageBatch.TryAddMessage(message)) {