private void ListeningLoop(object queueUrl) { _logger.Trace($"SiteSpeedJobQueueListener::ListeningLoop('{queueUrl}') >>"); while (!_cancellationTokenSource.IsCancellationRequested) { var receiveMessageResponse = _sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest() { QueueUrl = queueUrl.ToString(), MaxNumberOfMessages = 1, VisibilityTimeout = 60, WaitTimeSeconds = 20 }, _cancellationTokenSource.Token).Result; if (receiveMessageResponse.Messages.Count == 0) { _logger.Warn("ReceiveMessageAsync returned without any messages."); continue; } _logger.Debug($"Recieved message from ({queueUrl})"); var message = receiveMessageResponse.Messages.FirstOrDefault(); var details = _serializer.DeserializeFromString(message.Body); _siteSpeedProcess.Run(details); //_sqsClient.DeleteMessageAsync(queueUrl.ToString(), message.ReceiptHandle); } _logger.Trace($"SiteSpeedJobQueueListener::ListeningLoop('{queueUrl}') <<"); }