Ejemplo n.º 1
0
        protected async Task CycleAsync(IBatchCommand <T> batchCommand)
        {
            try
            {
                batchCommand.PreRun();

                bool continueProcessing;
                do
                {
                    continueProcessing = false;
                    foreach (var queueConfig in this.queuesConfiguration)
                    {
                        var messages = await queueConfig.Queue.GetMessagesAsync(queueConfig.BatchSize).ConfigureAwait(false);

                        await GenericQueueHandler <T> .ProcessMessagesAsync(queueConfig.Queue, messages, batchCommand.Run);

                        continueProcessing |= messages.Count() >= queueConfig.BatchSize;
                    }
                }while (continueProcessing);

                batchCommand.PostRun();

                this.Sleep(this.interval);
            }
            catch (TimeoutException ex)
            {
                TraceHelper.TraceWarning(ex.TraceInformation());
            }
        }
        protected async Task CycleAsync(ICommand <T> command)
        {
            try
            {
                await GenericQueueHandler <T> .ProcessMessagesAsync(this.queue, await this.queue.GetMessagesAsync(1), command.Run);

                // TODO: Change to Task.Await
                this.Sleep(this.interval);
            }
            catch (TimeoutException ex)
            {
                TraceHelper.TraceWarning(ex.TraceInformation());
            }
        }