Browse Source

Handle the exception in `InboxProcessor` and `OutboxSender`.

pull/11216/head
maliming 4 years ago
parent
commit
4cd2c86bd6
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 24
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs
  2. 24
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs

24
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs

@ -102,18 +102,26 @@ namespace Volo.Abp.EventBus.Boxes
foreach (var waitingEvent in waitingEvents) foreach (var waitingEvent in waitingEvents)
{ {
using (var uow = UnitOfWorkManager.Begin(isTransactional: true, requiresNew: true)) try
{ {
await DistributedEventBus using (var uow = UnitOfWorkManager.Begin(isTransactional: true, requiresNew: true))
.AsSupportsEventBoxes() {
.ProcessFromInboxAsync(waitingEvent, InboxConfig); await DistributedEventBus
.AsSupportsEventBoxes()
.ProcessFromInboxAsync(waitingEvent, InboxConfig);
await Inbox.MarkAsProcessedAsync(waitingEvent.Id); await Inbox.MarkAsProcessedAsync(waitingEvent.Id);
await uow.CompleteAsync(); await uow.CompleteAsync(StoppingToken);
}
Logger.LogInformation($"Processed the incoming event with id = {waitingEvent.Id:N}"); Logger.LogInformation($"Processed the incoming event with id = {waitingEvent.Id:N}");
}
}
catch (Exception e)
{
Logger.LogError($"An exception occurred when processed the incoming event with id = {waitingEvent.Id:N}");
Logger.LogException(e);
}
} }
} }
} }

24
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs

@ -85,15 +85,23 @@ namespace Volo.Abp.EventBus.Boxes
foreach (var waitingEvent in waitingEvents) foreach (var waitingEvent in waitingEvents)
{ {
await DistributedEventBus try
.AsSupportsEventBoxes() {
.PublishFromOutboxAsync( await DistributedEventBus
waitingEvent, .AsSupportsEventBoxes()
OutboxConfig .PublishFromOutboxAsync(
); waitingEvent,
OutboxConfig
);
await Outbox.DeleteAsync(waitingEvent.Id); await Outbox.DeleteAsync(waitingEvent.Id);
Logger.LogInformation($"Sent the event to the message broker with id = {waitingEvent.Id:N}"); Logger.LogInformation($"Sent the event to the message broker with id = {waitingEvent.Id:N}");
}
catch (Exception e)
{
Logger.LogError($"An exception occurred when sent the event to the message broker with id = {waitingEvent.Id:N}");
Logger.LogException(e);
}
} }
} }
} }

Loading…
Cancel
Save