Exemple #1
0
        public async Task <ICommandResult> Execute(ConsumerJobTask task)
        {
            var            saver  = factory.GetSaver(task.QueueParameters.Name);
            ICommandResult result = new CommandResult {
                Success = true
            };

            var approximateLength = await queue.GetQueueLength(task.QueueParameters.Name);

            for (int i = 0; i < approximateLength; i++)
            {
                var message = await queue.DequeueAsync(task.QueueParameters.Name);

                if (message != null)
                {
                    result = await saver.Save(message);

                    if (result.Success)
                    {
                        await queue.DeleteMessage(task.QueueParameters.Name, message);
                    }
                }
                else
                {
                    break;
                }
            }
            return(result);
        }