public override void Run() { Initialise(); while (true) { try { _vacancyEtlControlQueueConsumer.CheckScheduleQueue().Wait(); } catch (FaultException fe) { _logger.Error("FaultException from " + ProcessName, fe); } catch (CommunicationException ce) { _logger.Warn("CommunicationException from " + ProcessName, ce); } catch (TimeoutException te) { _logger.Warn("TimeoutException from " + ProcessName, te); } catch (Exception ex) { _logger.Error("Exception from " + ProcessName, ex); } Thread.Sleep(TimeSpan.FromMinutes(1)); } }
public override void Run() { Initialise(); while (true) { try { var tasks = new List <Task> { _savedSearchControlQueueConsumer.CheckScheduleQueue(), _vacancyEtlControlQueueConsumer.CheckScheduleQueue(), _housekeepingControlQueueConsumer.CheckScheduleQueue(), _vacancyStatusControlQueueConsumer.CheckScheduleQueue() }; if (CommunicationsIsEnabled) { _logger.Debug("Communications job is enabled"); tasks.Add(_dailyDigestControlQueueConsumer.CheckScheduleQueue()); } else { _logger.Debug("Communications job is disabled"); } Task.WaitAll(tasks.ToArray()); } catch (FaultException fe) { _logger.Error("FaultException from " + ProcessName, fe); } catch (CommunicationException ce) { _logger.Warn("CommunicationException from " + ProcessName, ce); } catch (TimeoutException te) { _logger.Warn("TimeoutException from " + ProcessName, te); } catch (Exception ex) { _logger.Error("Exception from " + ProcessName, ex); } Thread.Sleep(TimeSpan.FromMinutes(1)); } // ReSharper disable once FunctionNeverReturns }
public void ShouldKeepPoppingAndRemovingScheduleMessagesFromQueueUntilLastMessage(int queuedScheduledMessages) { var scheduledMessageQueue = GetScheduledMessagesQueue(queuedScheduledMessages); _messageServiceMock.Setup(x => x.GetMessage(It.IsAny <string>())).Returns(scheduledMessageQueue.Dequeue); var vacancyConsumer = new VacancyEtlControlQueueConsumer(_messageServiceMock.Object, _vacancySummaryProcessorMock.Object, _apprenticeshipIndexerService.Object, _traineeshipsIndexerService.Object, _logService.Object); var task = vacancyConsumer.CheckScheduleQueue(); task.Wait(); _messageServiceMock.Verify(x => x.GetMessage(It.Is <string>(queueName => queueName == ScheduledJobQueues.VacancyEtl)), Times.Exactly(queuedScheduledMessages + 1)); _messageServiceMock.Verify(x => x.DeleteMessage(It.Is <string>(queueName => queueName == ScheduledJobQueues.VacancyEtl), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(queuedScheduledMessages == 0 ? 0 : queuedScheduledMessages - 1)); _apprenticeshipIndexerService.Verify(x => x.CreateScheduledIndex(It.Is <DateTime>(d => d == DateTime.Today)), Times.Exactly(queuedScheduledMessages > 0 ? 1 : 0)); _vacancySummaryProcessorMock.Verify(x => x.ProcessVacancyPages(It.IsAny <StorageQueueMessage>()), Times.Exactly(queuedScheduledMessages == 0 ? 0 : 1)); }