public ProductQueryResponseItem[] DequeueProductQueryResponse(int messageId) { ProductQueryResponseItem[] products = null; var client = new QueueOf_ProductQueryRequest_ProductQueryResponseClient(); DateTime?dequeuedAt = null; var numberOfFailedAttempts = 0; Log.ForCurrent.DebugFormat("Dequeueing ProductQueryRequest. MessageId: {0}", messageId); for (var i = 0; i < _settings.MaximumNumberOfRetries; i++) { Thread.Sleep(_settings.MillisecondsBetweenRetries); products = client.DequeueMessage(messageId); if (products != null) { dequeuedAt = DateTime.Now; break; } numberOfFailedAttempts++; } _pimRequestLogRepository.UpdateRequestWithResponseData(messageId, dequeuedAt, numberOfFailedAttempts, products); return(products); }
public void Should_update_request() { // Arrange // Act _repository.UpdateRequestWithResponseData(_enqueuedRequestMessageId, DateTime.Now, 3, null); // Assert var lastMessages = _repository.GetRecentRequests(2); Assert.That(lastMessages.Any(msg => msg.MessageId == _enqueuedRequestMessageId && msg.NumberOfFailedAttemptsToDequeue == 3), Is.True); }