diff --git a/src/Foundatio.TestHarness/Queue/QueueTestBase.cs b/src/Foundatio.TestHarness/Queue/QueueTestBase.cs index 9687f0ba..c05fc411 100644 --- a/src/Foundatio.TestHarness/Queue/QueueTestBase.cs +++ b/src/Foundatio.TestHarness/Queue/QueueTestBase.cs @@ -1077,13 +1077,12 @@ public virtual async Task CanRunWorkItemWithMetricsAsync() { int completedCount = 0; - using var metrics = new InMemoryMetricsClient(new InMemoryMetricsClientOptions { Buffered = false, LoggerFactory = Log }); + using var metrics = new InMemoryMetricsClient(o => o.Buffered(false).LoggerFactory(Log)); #pragma warning disable CS0618 // Type or member is obsolete var behavior = new MetricsQueueBehavior(metrics, "metric", TimeSpan.FromMilliseconds(100), loggerFactory: Log); #pragma warning restore CS0618 // Type or member is obsolete - var options = new InMemoryQueueOptions { Behaviors = new[] { behavior }, LoggerFactory = Log }; - using var queue = new InMemoryQueue(options); + using var queue = new InMemoryQueue(o => o.Behaviors(behavior).LoggerFactory(Log)); Task Handler(object sender, CompletedEventArgs e) { @@ -1597,6 +1596,7 @@ public virtual async Task CanHandleAutoAbandonInWorker() await queue.StartWorkingAsync(async (item) => { + _logger.LogDebug("Processing item: {Id} Value={Value}", item.Id, item.Value.Data); if (item.Value.Data == "Delay") { // wait for queue item to get auto abandoned diff --git a/src/Foundatio/Queues/InMemoryQueue.cs b/src/Foundatio/Queues/InMemoryQueue.cs index 907766f5..4cf080e1 100644 --- a/src/Foundatio/Queues/InMemoryQueue.cs +++ b/src/Foundatio/Queues/InMemoryQueue.cs @@ -230,8 +230,8 @@ protected override async Task> DequeueImplAsync(CancellationToken Interlocked.Increment(ref _dequeuedCount); _logger.LogTrace("Dequeue: Got Item"); - await entry.RenewLockAsync(); ScheduleNextMaintenance(SystemClock.UtcNow.Add(_options.WorkItemTimeout)); + await entry.RenewLockAsync(); await OnDequeuedAsync(entry).AnyContext(); return entry; diff --git a/src/Foundatio/Utility/ScheduledTimer.cs b/src/Foundatio/Utility/ScheduledTimer.cs index 045e2daa..9ed16820 100644 --- a/src/Foundatio/Utility/ScheduledTimer.cs +++ b/src/Foundatio/Utility/ScheduledTimer.cs @@ -38,6 +38,7 @@ public void ScheduleNext(DateTime? utcDate = null) bool isTraceLogLevelEnabled = _logger.IsEnabled(LogLevel.Trace); if (isTraceLogLevelEnabled) _logger.LogTrace("ScheduleNext called: value={NextRun:O}", utcDate.Value); + if (utcDate == DateTime.MaxValue) { if (isTraceLogLevelEnabled) _logger.LogTrace("Ignoring MaxValue"); diff --git a/tests/Foundatio.Tests/Utility/ScheduledTimerTests.cs b/tests/Foundatio.Tests/Utility/ScheduledTimerTests.cs index 88d1265a..e8fb1a80 100644 --- a/tests/Foundatio.Tests/Utility/ScheduledTimerTests.cs +++ b/tests/Foundatio.Tests/Utility/ScheduledTimerTests.cs @@ -47,7 +47,6 @@ public Task CanRunWithMinimumInterval() private async Task CanRunConcurrentlyAsync(TimeSpan? minimumIntervalTime = null) { - Log.DefaultMinimumLevel = LogLevel.Trace; const int iterations = 2; var countdown = new AsyncCountdownEvent(iterations);