public void QueueVacancyPages(StorageQueueMessage scheduledQueueMessage) { _logger.Debug("Retrieving vacancy summary page count"); var vacancyPageCount = _vacancyIndexDataProvider.GetVacancyPageCount(); _logger.Info("Retrieved vacancy summary page count of {0}", vacancyPageCount); if (vacancyPageCount == 0) { _logger.Warn("Expected vacancy page count to be greater than zero. Indexes will not be created successfully"); _processControlQueue.DeleteMessage(scheduledQueueMessage.MessageId, scheduledQueueMessage.PopReceipt); return; } var vacancySumaries = BuildVacancySummaryPages(scheduledQueueMessage.ExpectedExecutionTime, vacancyPageCount).ToList(); foreach (var vacancySummaryPage in vacancySumaries) { _messageBus.PublishMessage(vacancySummaryPage); } // Only delete from queue once we have all vacancies from the service without error. _processControlQueue.DeleteMessage(scheduledQueueMessage.MessageId, scheduledQueueMessage.PopReceipt); _logger.Info("Queued {0} vacancy summary pages", vacancySumaries.Count()); }
protected StorageQueueMessage GetLatestQueueMessage() { _logger.Debug("Checking control queue for " + _processName + " process"); var queueMessage = MessageService.GetMessage(_queueName); if (queueMessage == null) { _logger.Debug("No control message found for " + _processName); return(null); } var foundSurplusMessages = false; while (true) { var nextQueueMessage = MessageService.GetMessage(_queueName); if (nextQueueMessage == null) { // We have the latest message on the queue. break; } MessageService.DeleteMessage(queueMessage.MessageId, queueMessage.PopReceipt, _queueName); queueMessage = nextQueueMessage; foundSurplusMessages = true; } if (foundSurplusMessages) { _logger.Warn("Found more than 1 control message for " + _processName + " process"); } _logger.Info("Found valid control message to start " + _processName + " process"); return(queueMessage); }