Skip to content

Commit

Permalink
Merge pull request #331 from Particular/hotfix-6.2.10
Browse files Browse the repository at this point in the history
Hotfix 6.2.10
  • Loading branch information
ramonsmits authored May 2, 2018
2 parents f3d9dd7 + cfb193a commit ca63cc4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/NServiceBus.NHibernate/Outbox/NHibernateOutboxStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace NServiceBus.Features
using System.Configuration;
using System.Threading;
using NHibernate.Mapping.ByCode;
using NServiceBus.Logging;
using NServiceBus.Outbox;
using NServiceBus.Outbox.NHibernate;
using Configuration = NHibernate.Cfg.Configuration;
Expand Down Expand Up @@ -80,7 +81,12 @@ protected override void OnStart()
}
}

cleanupTimer = new Timer(PerformCleanup, null, TimeSpan.FromMinutes(1), frequencyToRunDeduplicationDataCleanup);
if (Timeout.InfiniteTimeSpan == frequencyToRunDeduplicationDataCleanup)
{
Logger.InfoFormat("Outbox cleanup task is disabled.");
}

cleanupTimer = new Timer(PerformCleanup, null, frequencyToRunDeduplicationDataCleanup, Timeout.InfiniteTimeSpan);
}

protected override void OnStop()
Expand Down Expand Up @@ -109,8 +115,20 @@ void PerformCleanup(object state)
cleanupFailures = 0;
}
}
finally
{
try
{
cleanupTimer.Change(frequencyToRunDeduplicationDataCleanup, Timeout.InfiniteTimeSpan);
}
catch (ObjectDisposedException)
{
// Ignore, can happen during graceful shutdown.
}
}
}


static readonly ILog Logger = LogManager.GetLogger(typeof(OutboxCleaner));
// ReSharper disable NotAccessedField.Local
Timer cleanupTimer;
// ReSharper restore NotAccessedField.Local
Expand All @@ -121,4 +139,4 @@ void PerformCleanup(object state)
TimeSpan frequencyToRunDeduplicationDataCleanup;
}
}
}
}

0 comments on commit ca63cc4

Please sign in to comment.