Skip to content

Commit

Permalink
Catch and log sql exception when task cancellation requested (#300)
Browse files Browse the repository at this point in the history
* catch and log sql exception whe ncancellation requested

* Typo

* Typo
  • Loading branch information
tmasternak authored and Marcin Hoppe committed Oct 3, 2016
1 parent 6586b31 commit c6b84b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NServiceBus.Transport.SQLServer
{
using System;
using System.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Logging;
Expand Down Expand Up @@ -35,6 +36,11 @@ public async Task<int> Peek(TableBasedQueue inputQueue, RepeatedFailuresOverTime
}
catch (OperationCanceledException)
{
//Graceful shutdown
}
catch (SqlException e) when (cancellationToken.IsCancellationRequested)
{
Logger.Debug("Exception thrown during cancellation", e);
}
catch (Exception ex)
{
Expand All @@ -50,4 +56,4 @@ public async Task<int> Peek(TableBasedQueue inputQueue, RepeatedFailuresOverTime

static ILog Logger = LogManager.GetLogger<LegacyQueuePeeker>();
}
}
}
9 changes: 9 additions & 0 deletions src/NServiceBus.SqlServer/Receiving/MessagePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Collections.Concurrent;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -181,6 +186,10 @@ async Task PurgeExpiredMessages()
{
// Graceful shutdown
}
catch (SqlException e) when (cancellationToken.IsCancellationRequested)
{
Logger.Debug("Exception thown while performing cancellation", e);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/NServiceBus.SqlServer/Receiving/QueuePeeker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NServiceBus.Transport.SQLServer
{
using System;
using System.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Logging;
Expand Down Expand Up @@ -35,6 +36,11 @@ public async Task<int> 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)
{
Expand Down

0 comments on commit c6b84b6

Please sign in to comment.