/// <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);
        }
Exemple #2
0
 /// <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();
             }
     }
 }