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. 12
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/InboxProcessor.cs
  2. 8
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/OutboxSender.cs

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

@ -101,6 +101,8 @@ namespace Volo.Abp.EventBus.Boxes
Logger.LogInformation($"Found {waitingEvents.Count} events in the inbox.");
foreach (var waitingEvent in waitingEvents)
{
try
{
using (var uow = UnitOfWorkManager.Begin(isTransactional: true, requiresNew: true))
{
@ -110,12 +112,18 @@ namespace Volo.Abp.EventBus.Boxes
await Inbox.MarkAsProcessedAsync(waitingEvent.Id);
await uow.CompleteAsync();
}
await uow.CompleteAsync(StoppingToken);
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);
}
}
}
}
else
{

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

@ -84,6 +84,8 @@ namespace Volo.Abp.EventBus.Boxes
Logger.LogInformation($"Found {waitingEvents.Count} events in the outbox.");
foreach (var waitingEvent in waitingEvents)
{
try
{
await DistributedEventBus
.AsSupportsEventBoxes()
@ -95,6 +97,12 @@ namespace Volo.Abp.EventBus.Boxes
await Outbox.DeleteAsync(waitingEvent.Id);
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);
}
}
}
}
else

Loading…
Cancel
Save