Пример #1
0
        public async Task QueryAsync(CancellationToken ct)
        {
            if (currentHandler == null)
            {
                return;
            }

            while (!ct.IsCancellationRequested)
            {
                try
                {
                    var time = clock.GetCurrentInstant();

                    var document = await schedulerStore.DequeueAsync(time);

                    if (document == null)
                    {
                        var oldTime = time.PlusTicks(-schedulerOptions.FailedTimeout.Ticks);

                        await schedulerStore.ResetDeadAsync(oldTime, time);

                        break;
                    }

                    await actionBlock.SendAsync(document, ct);
                }
                catch (Exception ex)
                {
                    log.LogError(ex, w => w
                                 .WriteProperty("action", "DequeueJobs")
                                 .WriteProperty("status", "Failed"));
                }
            }
        }
Пример #2
0
        public async Task QueryAsync(
            CancellationToken ct)
        {
            using (Telemetry.Activities.StartActivity(activity))
            {
                while (!ct.IsCancellationRequested)
                {
                    try
                    {
                        var time = clock.GetCurrentInstant();

                        var document = await schedulerStore.DequeueAsync(time, ct);

                        if (document == null)
                        {
                            var oldTime = time.PlusTicks(-schedulerOptions.FailedTimeout.Ticks);

                            // If we are not busy, we can reset the dead entries.
                            await schedulerStore.ResetDeadAsync(oldTime, time, ct);

                            // If nothing has been queried we end our loop, if somethine has been returned it is very likely there is something else.
                            break;
                        }

                        await actionBlock.SendAsync(document, ct);
                    }
                    catch (Exception ex)
                    {
                        log.LogError(ex, "Failed to dequeue job.");
                    }
                }
            }
        }