Example #1
0
        protected void Cycle(IBatchCommand <T> batchCommand)
        {
            try
            {
                batchCommand.PreRun();

                int  batches = 0;
                bool continueProcessing;
                do
                {
                    continueProcessing = false;
                    foreach (var queueConfig in this.queuesConfiguration)
                    {
                        var messages = queueConfig.Queue.GetMessages(queueConfig.BatchSize);
                        GenericQueueHandler <T> .ProcessMessages(queueConfig.Queue, messages, batchCommand.Run);

                        continueProcessing |= messages.Count() >= queueConfig.BatchSize;
                    }
                    batches++;
                }while (continueProcessing && batches < this.maxBatchesPerCycle);

                batchCommand.PostRun();

                this.Sleep(this.interval);
            }
            catch (TimeoutException ex)
            {
                TraceHelper.TraceWarning(ex.TraceInformation());
            }
            catch (Exception ex)
            {
                // no exception should get here - we don't want the handler to stop (we log it as ERROR)
                TraceHelper.TraceError(ex.TraceInformation());
            }
        }
Example #2
0
        protected void Cycle(ICommand <T> command)
        {
            try
            {
                GenericQueueHandler <T> .ProcessMessages(this.queue, this.queue.GetMessages(1), command.Run);

                this.Sleep(this.interval);
            }
            catch (TimeoutException ex)
            {
                TraceHelper.TraceWarning(ex.TraceInformation());
            }
            catch (Exception ex)
            {
                // no exception should get here - we don't want the handler to stop (we log it as ERROR)
                TraceHelper.TraceError(ex.TraceInformation());
            }
        }