public AdaptationResponseProducer(IFileManager fileManager, IAdaptationRequestSender adaptationRequestSender, IArchiveProcessorConfig config, ILogger <AdaptationResponseProducer> logger) { _fileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager)); _adaptationRequestSender = adaptationRequestSender ?? throw new ArgumentNullException(nameof(adaptationRequestSender)); _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public AdaptationResponseConsumer(IAdaptationResponseCollection collection, IArchiveManager archiveManager, IErrorReportGenerator errorReportGenerator, IFileManager fileManager, IArchiveProcessorConfig config, ILogger <AdaptationResponseConsumer> logger) { _collection = collection ?? throw new ArgumentNullException(nameof(collection)); _archiveManager = archiveManager ?? throw new ArgumentNullException(nameof(archiveManager)); _errorReportGenerator = errorReportGenerator ?? throw new ArgumentNullException(nameof(errorReportGenerator)); _fileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager)); _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public HtmlErrorReportGenerator(IArchiveProcessorConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } using (var reader = File.OpenText("Templates/ArchiveErrorReportTemplate.html")) { _report = reader.ReadToEnd(); var builder = new StringBuilder(_report); builder.Replace("{{MESSAGE}}", config.ArchiveErrorReportMessage ?? DefaultMessage); _report = builder.ToString(); } }
public ArchiveProcessor( IAdaptationOutcomeSender adaptationOutcomeSender, IFileManager fileManager, IArchiveManager archiveManager, IAdaptationResponseProducer responseProducer, IAdaptationResponseConsumer responseConsumer, IPasswordProtectedReportGenerator passwordProtectedReportGenerator, IArchiveProcessorConfig config, ILogger <ArchiveProcessor> logger) { _adaptationOutcomeSender = adaptationOutcomeSender ?? throw new ArgumentNullException(nameof(adaptationOutcomeSender)); _fileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager)); _archiveManager = archiveManager ?? throw new ArgumentNullException(nameof(archiveManager)); _responseProducer = responseProducer ?? throw new ArgumentNullException(nameof(responseProducer)); _responseConsumer = responseConsumer ?? throw new ArgumentNullException(nameof(responseConsumer)); _passwordProtectedReportGenerator = passwordProtectedReportGenerator ?? throw new ArgumentNullException(nameof(passwordProtectedReportGenerator)); _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _processingTimeoutDuration = _config.ProcessingTimeoutDuration; _cancellationTokenSource = new CancellationTokenSource(); }
public AdaptationOutcomeSender(ILogger <AdaptationOutcomeSender> logger, IArchiveProcessorConfig config) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); if (config == null) { throw new ArgumentNullException(nameof(config)); } var connectionFactory = new ConnectionFactory() { HostName = config.AdaptationRequestQueueHostname, Port = config.AdaptationRequestQueuePort, UserName = config.MessageBrokerUser, Password = config.MessageBrokerPassword }; _connection = connectionFactory.CreateConnection(); _channel = _connection.CreateModel(); _logger.LogInformation($"AdaptationOutcomeSender Connection established to {config.AdaptationRequestQueueHostname}"); }
public AdaptationRequestSender(IResponseProcessor responseProcessor, IAdaptationResponseCollection collection, ILogger <AdaptationRequestSender> logger, IArchiveProcessorConfig config) { _responseProcessor = responseProcessor ?? throw new ArgumentNullException(nameof(responseProcessor)); _collection = collection ?? throw new ArgumentNullException(nameof(collection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); if (config == null) { throw new ArgumentNullException(nameof(config)); } var connectionFactory = new ConnectionFactory() { HostName = config.AdaptationRequestQueueHostname, Port = config.AdaptationRequestQueuePort, UserName = config.MessageBrokerUser, Password = config.MessageBrokerPassword }; _connection = connectionFactory.CreateConnection(); _channel = _connection.CreateModel(); _consumer = new EventingBasicConsumer(_channel); _channel.BasicConsume(_consumer, "amq.rabbitmq.reply-to", autoAck: true); _consumer.Received += (model, ea) => { try { _receivedMessageCount++; _logger.LogInformation($"Received message: Exchange Name: '{ea.Exchange}', Routing Key: '{ea.RoutingKey}'"); var headers = ea.BasicProperties.Headers; var body = ea.Body.ToArray(); var response = _responseProcessor.Process(headers); _collection.Add(response); } catch (Exception ex) { _logger.LogError(ex, $"Error Processing 'input'"); _collection.Add(new KeyValuePair <Guid, AdaptationOutcome>(Guid.Empty, AdaptationOutcome.Error)); } }; _logger.LogInformation($"AdaptationRequestSender Connection established to {config.AdaptationRequestQueueHostname}"); }
public HtmlPasswordProtectedErrorReportGenerator(IArchiveProcessorConfig config) { _config = config ?? throw new ArgumentNullException(nameof(config)); }