public async Task Send(AutoScheduleMessage message) { if (message == null) { this._logger.LogWarning( "UploadCoordinatorMessageSender was asked to send a null message. Will not be sending anything."); return; } var messageBusCts = new CancellationTokenSource(); var serialisedMessage = this._serialiser.Serialise(message); try { this._logger.LogInformation( $"UploadCoordinatorMessageSender dispatching to {this._awsConfiguration.UploadCoordinatorQueueName}"); await this._awsQueueClient.SendToQueue( this._awsConfiguration.UploadCoordinatorQueueName, serialisedMessage, messageBusCts.Token); this._logger.LogInformation( $"UploadCoordinatorMessageSender finished dispatching to {this._awsConfiguration.UploadCoordinatorQueueName}"); } catch (Exception e) { this._logger.LogError(e, $"Exception in UploadCoordinatorMessageSender sending message '{message}' to bus on queue {this._awsConfiguration.UploadCoordinatorQueueName}."); } }
private void InsertFileUploadOrderIds( IReadOnlyCollection <Order> orders, ISystemProcessOperationUploadFileContext fileUpload) { if (orders == null || !orders.Any()) { return; } if (fileUpload?.FileUpload?.Id == null) { return; } var orderIds = orders.Select(i => i.ReddeerOrderId?.ToString()).Where(i => !string.IsNullOrWhiteSpace(i)) .ToList(); this._logger.LogInformation( $"{fileUpload.FileUpload.Id} has uploaded the {orders.Count} csv records. Now about to save the link between the file upload and orders"); this._fileUploadOrdersRepository.Create(orderIds, fileUpload.FileUpload.Id).Wait(); this._logger.LogInformation( $"{fileUpload.FileUpload.Id} has uploaded the {orders.Count} csv records. Completed saving the link between the file upload and orders"); var uploadMessage = new AutoScheduleMessage(); this._fileUploadMessageSender.Send(uploadMessage).Wait(); }
public async Task ExecuteCoordinationMessageCallsAnalyseFileIdForValidUploadMessage() { var subscriber = new QueueAutoScheduleSubscriber( this.dataVerifier, this.autoSchedule, this.awsQueueClient, this.awsConfiguration, this.serialiser, this.systemProcessContext, this.logger); var uploadMessage = new AutoScheduleMessage(); var message = this.serialiser.Serialise(uploadMessage); await subscriber.ExecuteCoordinationMessageAsync("message-id", message); A.CallTo(() => this.dataVerifier.Scan()).MustHaveHappenedOnceExactly(); }
private void LinkFileUploadDataToUpload( ISystemProcessOperationUploadFile fileUploadId, IReadOnlyCollection <string> allocationIds) { if (allocationIds == null || !allocationIds.Any()) { this.Logger.LogInformation( "AllocationFileMonitor had no inserted allocation ids to link the file upload to."); return; } if (fileUploadId?.Id != null) { this._fileUploadRepository.Create(allocationIds, fileUploadId.Id).Wait(); var uploadMessage = new AutoScheduleMessage(); this._messageSender.Send(uploadMessage).Wait(); } else { this.Logger.LogInformation("AllocationFileMonitor received a null or empty file upload id. Exiting"); } }