Table of Contents

Class SchedulerBackfillExtensions

Namespace
Quartz
Assembly
Quartz.dll

Running a trigger's schedule over a past range you choose: one firing per slot the trigger had in it.

public static class SchedulerBackfillExtensions
Inheritance
SchedulerBackfillExtensions
Inherited Members

Remarks

An extension rather than an IScheduler member: it reads the trigger and its calendar and schedules one-shot triggers, all through members every scheduler has, so it works unchanged through any forwarder. HttpScheduler sends it to its host as one request instead, which backfills there.

A misfire instruction decides what happens to the firings a scheduler missed while it was down. A backfill is the other case: a range somebody decides, however the trigger got through it.

Methods

Backfill(IScheduler, TriggerKey, DateTimeOffset, DateTimeOffset, BackfillOptions, CancellationToken)

Schedules one firing of the trigger's job for each slot the trigger had in [from, to).

public static ValueTask<BackfillResult> Backfill(this IScheduler scheduler, TriggerKey triggerKey, DateTimeOffset from, DateTimeOffset to, BackfillOptions options = default, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler holding the trigger.

triggerKey TriggerKey

The trigger whose schedule to backfill.

from DateTimeOffset

The start of the range, included.

to DateTimeOffset

The end of the range, excluded. Not later than the scheduler's current time.

options BackfillOptions

How many slots may be scheduled, their spacing and their execution group.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<BackfillResult>

The slots found, the triggers scheduled, and the slots already scheduled.

Remarks

A slot is a fire time of the trigger — its start and end time honoured — that its calendar does not exclude. There are none before its start time, which a trigger builder sets to the moment it builds unless told otherwise, and which a simple trigger moves forward when it is stored with one in the past or a misfire reschedules it. Each slot gets a one-shot trigger in group BackfillGroupPrefix + the trigger's group, named {trigger name}@{slot in UTC, ISO 8601}, for the same job. It carries the trigger's JobDataMap with the slot added under BackfillOriginalFireTime, its priority, retry policy, preferred node and execution group, and the FireNow misfire instruction. It carries no calendar: the slot has already been checked against it.

The name is the slot, so running the same range again skips every slot whose trigger is still stored — waiting, paused or firing — and counts it in AlreadyScheduled. A slot whose trigger has fired is gone from the store and is scheduled again.

The slots are scheduled one call at a time. A failure or a cancellation part way leaves the ones already scheduled in place; running the same range again schedules the rest.

On an HttpScheduler the whole backfill is one request to the host's backfill route: the host's clock decides what "now" is, and its audit records one backfill. A host older than 4.3 has no such route, and is backfilled through the reads and writes it has instead.

Exceptions

ArgumentNullException

scheduler or triggerKey is null.

ArgumentException

to is not after from; to is later than the scheduler's TimeProvider says it is now; the range holds more slots than MaxSlots; or an option is out of range. Nothing is scheduled.

ObjectDoesNotExistException

There is no trigger under triggerKey, or the calendar it names is gone. Nothing is scheduled.