Ejemplo n.º 1
0
        /// <summary>Do not try to override this method, use <see cref="Start"/> instead.</summary>
        protected sealed override ServiceExecutionFeedback StartImpl()
        {
            try
            {
                if (_resilientDequeue)
                {
                    using (var message = Queues.GetResilient <T>(_queueName, _resilientAfter, _maxProcessingTrials))
                    {
                        if (message == null)
                        {
                            return(ServiceExecutionFeedback.Skipped);
                        }

                        ProcessMessage(message.Message);
                        return(ServiceExecutionFeedback.WorkAvailable);
                    }
                }

                var messages = Queues.Get <T>(_queueName, 1, _visibilityTimeout, _maxProcessingTrials).ToList();
                if (messages.Count == 0)
                {
                    return(ServiceExecutionFeedback.Skipped);
                }

                ProcessMessage(messages[0]);
                return(ServiceExecutionFeedback.WorkAvailable);
            }
            finally
            {
                Queues.AbandonAll();
            }
        }