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 49add5df84..3bc51216e6 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 @@ -87,7 +87,7 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen public override async Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig) { - await PublishAsync(outgoingEvent.EventName, outgoingEvent.EventData); + await PublishAsync(outgoingEvent.EventName, outgoingEvent.EventData, outgoingEvent.Id); } public override async Task ProcessFromInboxAsync(IncomingEventInfo incomingEvent, InboxConfig inboxConfig) @@ -188,15 +188,28 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen unitOfWork.AddOrReplaceDistributedEvent(eventRecord); } - protected virtual async Task PublishAsync(string eventName, object eventData) + protected virtual Task PublishAsync(string eventName, object eventData) { var body = _serializer.Serialize(eventData); + return PublishAsync(eventName, body, null); + } + + protected virtual async Task PublishAsync( + string eventName, + byte[] body, + Guid? eventId) + { var message = new ServiceBusMessage(body) { Subject = eventName }; + if (message.MessageId.IsNullOrWhiteSpace()) + { + message.MessageId = (eventId ?? GuidGenerator.Create()).ToString("N"); + } + var publisher = await _publisherPool.GetAsync( _options.TopicName, _options.ConnectionName);