/// <summary> /// Puts fetched job into a queue /// </summary> public virtual void Requeue() { _connection.JobGraph.OfType <JobQueueDto>().FindOneAndUpdate( Builders <JobQueueDto> .Filter.Eq(_ => _.Id, _id), Builders <JobQueueDto> .Update.Set(_ => _.FetchedAt, null)); _connection.Notifications.InsertOne(NotificationDto.JobEnqueued(Queue), new InsertOneOptions { BypassDocumentValidation = false }); if (Logger.IsTraceEnabled()) { Logger.Trace($"Requeue job '{JobId}' from queue '{Queue}'"); } _requeued = true; }
public void Execute_JobEnqueued_Signaled() { // ARRANGE var signal = new SemaphoreSlim(0, 1); _jobQueueSemaphoreMock.Setup(m => m.Release("test")) .Callback(() => signal.Release()); // ACT _dbContext.Notifications.InsertOne(NotificationDto.JobEnqueued("test")); signal.Wait(1000); // ASSERT _jobQueueSemaphoreMock.Verify(m => m.Release("test"), Times.Once); _distributedLockMutexMock.Verify(m => m.Release(It.IsAny <string>()), Times.Never); }