Browse Source

Fix Azure event bus publishing issue

pull/11249/head
liangshiwei 4 years ago
parent
commit
e4b5ed0527
  1. 17
      framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs

17
framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs

@ -87,7 +87,7 @@ namespace Volo.Abp.EventBus.Azure
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 @@ namespace Volo.Abp.EventBus.Azure
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);

Loading…
Cancel
Save