/// <summary> /// Creates a new instance of the <see cref="DownloadService"/> class. /// </summary> /// <param name="innerEyeSegmentationClient">Optional InnerEye segmentation client.</param> /// <param name="dequeueServiceConfig">Optional dequeue service config.</param> /// <param name="instances">The number of concurrent execution instances we should have.</param> /// <returns>New DownloadService.</returns> protected DownloadService CreateDownloadService( IInnerEyeSegmentationClient innerEyeSegmentationClient = null, DequeueServiceConfig dequeueServiceConfig = null, int instances = 1) => new DownloadService( innerEyeSegmentationClient != null ? () => innerEyeSegmentationClient : TestGatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(), TestDownloadQueuePath, TestPushQueuePath, TestDeleteQueuePath, () => new DownloadServiceConfig(), dequeueServiceConfig != null ? (Func <DequeueServiceConfig>)(() => dequeueServiceConfig) : TestGatewayProcessorConfigProvider.DequeueServiceConfig, _loggerFactory.CreateLogger("DownloadService"), instances);
/// <summary> /// Initializes a new instance of the <see cref="DequeueClientServiceBase"/> class. /// </summary> /// <param name="getDequeueServiceConfig">Callback for dequeue service config.</param> /// <param name="dequeueQueuePath">The dequeue queue path.</param> /// <param name="logger">The listener log.</param> /// <param name="instances">The number of concurrent execution instances we should have.</param> protected DequeueClientServiceBase( Func <DequeueServiceConfig> getDequeueServiceConfig, string dequeueQueuePath, ILogger logger, int instances) : base(logger, instances) { _getDequeueServiceConfig = getDequeueServiceConfig ?? throw new ArgumentNullException(nameof(getDequeueServiceConfig)); // We create the dequeue and dead letter queue on construction. This can throw exceptions. _dequeueQueuePath = !string.IsNullOrWhiteSpace(dequeueQueuePath) ? dequeueQueuePath : throw new ArgumentException("The dequeue queue path is null or white space.", nameof(dequeueQueuePath)); _deadLetterQueuePath = DequeueServiceConfig.DeadLetterQueuePath(dequeueQueuePath); }
/// <summary> /// Clears all the queues and its corresponding dead letter queue. /// </summary> /// <param name="queuePaths">Queue paths.</param> private static void ClearQueues(params string[] queuePaths) { foreach (var path in queuePaths) { // Note that this must be the same as DequeueClientServiceBase.DeadLetterQueuePathFormat. using (var deadLetterQueue = GatewayMessageQueue.Get(DequeueServiceConfig.DeadLetterQueuePath(path))) using (var queue = GatewayMessageQueue.Get(path)) { deadLetterQueue.Clear(); queue.Clear(); } } }
/// <summary> /// Called when the service is started. /// </summary> protected override void OnServiceStart() { _dequeueServiceConfig = _getDequeueServiceConfig(); }