diff --git a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueuePeeker.cs b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueuePeeker.cs index 7ad71b068..6a21b2f05 100644 --- a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueuePeeker.cs +++ b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueuePeeker.cs @@ -1,6 +1,7 @@ namespace NServiceBus.Transport.SQLServer { using System; + using System.Data.SqlClient; using System.Threading; using System.Threading.Tasks; using Logging; @@ -35,6 +36,11 @@ public async Task Peek(TableBasedQueue inputQueue, RepeatedFailuresOverTime } catch (OperationCanceledException) { + //Graceful shutdown + } + catch (SqlException e) when (cancellationToken.IsCancellationRequested) + { + Logger.Debug("Exception thrown during cancellation", e); } catch (Exception ex) { @@ -50,4 +56,4 @@ public async Task Peek(TableBasedQueue inputQueue, RepeatedFailuresOverTime static ILog Logger = LogManager.GetLogger(); } -} \ No newline at end of file +} diff --git a/src/NServiceBus.SqlServer/Receiving/MessagePump.cs b/src/NServiceBus.SqlServer/Receiving/MessagePump.cs index b7dd4d6ef..092ded079 100644 --- a/src/NServiceBus.SqlServer/Receiving/MessagePump.cs +++ b/src/NServiceBus.SqlServer/Receiving/MessagePump.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Concurrent; + using System.Data.SqlClient; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -92,6 +93,10 @@ async Task ProcessMessages() { // For graceful shutdown purposes } + catch (SqlException e) when (cancellationToken.IsCancellationRequested) + { + Logger.Debug("Exception thrown during cancellation", e); + } catch (Exception ex) { Logger.Error("Sql Message pump failed", ex); @@ -181,6 +186,10 @@ async Task PurgeExpiredMessages() { // Graceful shutdown } + catch (SqlException e) when (cancellationToken.IsCancellationRequested) + { + Logger.Debug("Exception thown while performing cancellation", e); + } } } diff --git a/src/NServiceBus.SqlServer/Receiving/QueuePeeker.cs b/src/NServiceBus.SqlServer/Receiving/QueuePeeker.cs index 9f12e3999..39e2925e6 100644 --- a/src/NServiceBus.SqlServer/Receiving/QueuePeeker.cs +++ b/src/NServiceBus.SqlServer/Receiving/QueuePeeker.cs @@ -1,6 +1,7 @@ namespace NServiceBus.Transport.SQLServer { using System; + using System.Data.SqlClient; using System.Threading; using System.Threading.Tasks; using Logging; @@ -35,6 +36,11 @@ public async Task Peek(TableBasedQueue inputQueue, RepeatedFailuresOverTime } catch (OperationCanceledException) { + //Graceful shutdown + } + catch (SqlException e) when (cancellationToken.IsCancellationRequested) + { + Logger.Debug("Exception thown while performing cancellation", e); } catch (Exception ex) {