From ee89331b9159abbd3cb53e1c1fdaa45837218f5a Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 21 Dec 2020 14:21:19 +0100 Subject: [PATCH] Handle ServiceBusCommunicationException --- .../Services/QueueWorker.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/activities/Elsa.Activities.AzureServiceBus/Services/QueueWorker.cs b/src/activities/Elsa.Activities.AzureServiceBus/Services/QueueWorker.cs index e9e93f54e..97fdc5d5d 100644 --- a/src/activities/Elsa.Activities.AzureServiceBus/Services/QueueWorker.cs +++ b/src/activities/Elsa.Activities.AzureServiceBus/Services/QueueWorker.cs @@ -46,17 +46,19 @@ namespace Elsa.Activities.AzureServiceBus.Services { var context = e.ExceptionReceivedContext; - if (e.Exception is MessageLockLostException) + switch (e.Exception) { - _logger.LogDebug("Message lock lost."); - } - else - { - _logger.LogError("Message handler encountered an exception {Exception}.", e.Exception); - _logger.LogError("Exception context for troubleshooting:"); - _logger.LogError("- Endpoint: {Endpoint}", context.Endpoint); - _logger.LogError("- Entity Path: {EntityPath}", context.EntityPath); - _logger.LogError("- Executing Action: {Action}", context.Action); + case MessageLockLostException: + case ServiceBusCommunicationException: + _logger.LogDebug(e.Exception.Message); + break; + default: + _logger.LogError("Message handler encountered an exception {Exception}.", e.Exception); + _logger.LogError("Exception context for troubleshooting:"); + _logger.LogError("- Endpoint: {Endpoint}", context.Endpoint); + _logger.LogError("- Entity Path: {EntityPath}", context.EntityPath); + _logger.LogError("- Executing Action: {Action}", context.Action); + break; } return Task.CompletedTask;