예제 #1
0
        public async Task EnqueueForAsyncProcessingAsync(IReadOnlyCollection <IAsyncEventQueueRecord> eventsToProcess, TimeSpan?timeDelay)
        {
            string[] queues = eventsToProcess.Select(x => x.QueueName).Distinct().ToArray();
            var      jobs   = queues.Select(x => new ProcessAsyncEventsJob(x, asyncEventPipelineConfiguration.AsyncProcessAttemptCount, asyncEventPipelineConfiguration.AsyncProcessRetryTimeout));

            foreach (ProcessAsyncEventsJob job in jobs)
            {
                await jobScheduler.EnqeueJobAsync(job, timeDelay);
            }
        }
예제 #2
0
        private async Task ScheduleRetryAsync(ProcessAsyncEventsJob job)
        {
            if (job.AttemptsLeft > 1)
            {
                TimeSpan timeout = TimeSpan.FromTicks(job.RetryTimeout.Ticks *
                                                      asyncEventPipelineConfiguration.AsyncProcessRetryTimeoutMultiplier);
                Logger.Debug($"Scheduling '{job.QueueName}' async event queue processing retry in {timeout.TotalSeconds} seconds");

                ProcessAsyncEventsJob newJob = new ProcessAsyncEventsJob(job.QueueName, job.AttemptsLeft - 1, timeout);
                await jobScheduler.EnqeueJobAsync(newJob, job.RetryTimeout);
            }
            else
            {
                Logger.Error($"Unable to finish '{job.QueueName}' async event queue even after {asyncEventPipelineConfiguration.AsyncProcessAttemptCount} attempts, giving up");
            }
        }
예제 #3
0
 public Task HandleAsync(IEnqueueJobCommand command, CancellationToken cancellationToken)
 {
     return(jobScheduler.EnqeueJobAsync(GetCommandJob((dynamic)command.Command), command.TimeDelay));
 }