From 2c405ba135b18c6995371ff47b613fdddfe7156f Mon Sep 17 00:00:00 2001 From: John Simons Date: Thu, 16 Apr 2015 16:53:59 +1000 Subject: [PATCH] Adding queue name to the trace logging --- src/NServiceBus.SqlServer/AdaptiveExecutor.cs | 2 +- .../AdaptivePollingReceiver.cs | 2 +- .../ReceiveTaskTracker.cs | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/NServiceBus.SqlServer/AdaptiveExecutor.cs b/src/NServiceBus.SqlServer/AdaptiveExecutor.cs index 7d882bb2d..45edc4b9e 100644 --- a/src/NServiceBus.SqlServer/AdaptiveExecutor.cs +++ b/src/NServiceBus.SqlServer/AdaptiveExecutor.cs @@ -65,7 +65,7 @@ void StartTask() StartTask(); }, taskId, token); - + return Tuple.Create(taskId, receiveTask); }); } diff --git a/src/NServiceBus.SqlServer/AdaptivePollingReceiver.cs b/src/NServiceBus.SqlServer/AdaptivePollingReceiver.cs index a0bd7557e..6cb1a99ae 100644 --- a/src/NServiceBus.SqlServer/AdaptivePollingReceiver.cs +++ b/src/NServiceBus.SqlServer/AdaptivePollingReceiver.cs @@ -12,7 +12,7 @@ public AdaptivePollingReceiver( TableBasedQueue queue, Action endProcessMessage, RepeatedFailuresOverTimeCircuitBreaker circuitBreaker, - TransportNotifications transportNotifications) + TransportNotifications transportNotifications) : base(circuitBreaker) { this.receiveStrategy = receiveStrategy; diff --git a/src/NServiceBus.SqlServer/ReceiveTaskTracker.cs b/src/NServiceBus.SqlServer/ReceiveTaskTracker.cs index 917c82fe3..bf875115f 100644 --- a/src/NServiceBus.SqlServer/ReceiveTaskTracker.cs +++ b/src/NServiceBus.SqlServer/ReceiveTaskTracker.cs @@ -15,20 +15,20 @@ public ReceiveTaskTracker(int maximumConcurrency, TransportNotifications transpo this.queueName = queueName; } - public void StartAndTrack(Func> taskFactory) + public void StartAndTrack(Func> taskFactory) { lock (lockObj) { if (shuttingDown) { - Logger.Debug("Ignoring start task request because shutdown is in progress."); + Logger.DebugFormat("Ignoring start task request for '{0}' because shutdown is in progress.", queueName); return; } if (trackedTasks.Count >= maximumConcurrency) { if (Logger.IsDebugEnabled) { - Logger.DebugFormat("Ignoring start task request because of maximum concurrency limit {0}", maximumConcurrency); + Logger.DebugFormat("Ignoring start task request for '{0}' because of maximum concurrency limit of {1} has been reached.", queueName, maximumConcurrency); } transportNotifications.InvokeMaximumConcurrencyLevelReached(queueName, maximumConcurrency); return; @@ -37,7 +37,7 @@ public void StartAndTrack(Func> taskFactory) trackedTasks.Add(tuple.Item1, tuple.Item2); if (Logger.IsDebugEnabled) { - Logger.DebugFormat("Starting a new receive task. Total count current/max {0}/{1}", trackedTasks.Count, maximumConcurrency); + Logger.DebugFormat("Starting a new receive task for '{0}'. Total count current/max {1}/{2}", queueName, trackedTasks.Count, maximumConcurrency); } transportNotifications.InvokeReceiveTaskStarted(queueName, trackedTasks.Count, maximumConcurrency); } @@ -51,12 +51,15 @@ public void Forget(Guid id) { return; } - trackedTasks.Remove(id); - if (Logger.IsDebugEnabled) + + if (trackedTasks.Remove(id)) { - Logger.DebugFormat("Stopping a receive task. Total count current/max {0}/{1}", trackedTasks.Count, maximumConcurrency); + if (Logger.IsDebugEnabled) + { + Logger.DebugFormat("Stopping a receive task for '{0}'. Total count current/max {1}/{2}", queueName, trackedTasks.Count, maximumConcurrency); + } + transportNotifications.InvokeReceiveTaskStopped(queueName, trackedTasks.Count, maximumConcurrency); } - transportNotifications.InvokeReceiveTaskStopped(queueName, trackedTasks.Count, maximumConcurrency); } }