Table of Contents

Interface ISchedulerListener

Namespace
Quartz
Assembly
Quartz.dll

The interface to be implemented by classes that want to be informed of major IScheduler events.

public interface ISchedulerListener

Remarks

Every callback is told which scheduler is calling it: a listener reaches the scheduler it serves through its execution context, or as its first argument when there is no execution. No member here is handed an execution context, so every one of them takes the scheduler. One listener instance can therefore serve several schedulers in one host and still say which of them paused a trigger or failed.

Every member has a default implementation, so an implementation only has to write the notifications it cares about. Name defaults to the implementing type's name.

Properties

Name

The name this listener is registered and removed under.

string Name { get; }

Property Value

string

Remarks

Defaults to the implementing type's name, which is the right answer whenever a scheduler has at most one listener of a given type. Override it when several instances of one type are registered with the same scheduler, because the later registration would otherwise replace the earlier one.

Methods

JobAdded(IScheduler, IJobDetail, CancellationToken)

Called by the IScheduler when a IJobDetail has been added.

ValueTask JobAdded(IScheduler scheduler, IJobDetail jobDetail, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobDetail IJobDetail

The job that was added.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

JobDeleted(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when a IJobDetail has been deleted.

ValueTask JobDeleted(IScheduler scheduler, JobKey jobKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job that was deleted.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

JobInterrupted(IScheduler, JobKey, string, CancellationToken)

Called by the IScheduler when one firing of a IJobDetail has been interrupted.

ValueTask JobInterrupted(IScheduler scheduler, JobKey jobKey, string fireInstanceId, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job whose firing was interrupted.

fireInstanceId string

The firing that was interrupted, which is FireInstanceId.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

A job without DisallowConcurrentExecutionAttribute can have several firings in flight at once, and the key names all of them — so a listener told only the key could not say which execution was cancelled, could not correlate the interruption with the firing's own JobToBeExecuted/JobWasExecuted notifications, and could not tell one Interrupt(jobKey) that cancelled four firings from one that cancelled one.

Interrupt(JobKey, CancellationToken) raises this once per firing it cancelled; InterruptFireInstance(string, CancellationToken) raises it once. The default body calls the key-only overload, so an existing listener keeps working — and gets one call per interrupted firing where it used to get one per call.

JobInterrupted(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when a IJobDetail has been interrupted.

ValueTask JobInterrupted(IScheduler scheduler, JobKey jobKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job that was interrupted.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The scheduler raises the JobInterrupted(IScheduler, JobKey, string, CancellationToken) overload, which says which firing was interrupted; this one is what that overload's default body calls, so a listener written before the fire instance id existed keeps hearing about every interruption. Implement one or the other, not both.

JobPaused(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when a IJobDetail has been paused.

ValueTask JobPaused(IScheduler scheduler, JobKey jobKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job that was paused.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

JobResumed(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when a IJobDetail has been un-paused.

ValueTask JobResumed(IScheduler scheduler, JobKey jobKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job that was resumed.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

JobScheduled(IScheduler, ITrigger, CancellationToken)

Called by the IScheduler when a IJobDetail is scheduled.

ValueTask JobScheduled(IScheduler scheduler, ITrigger trigger, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

trigger ITrigger

The trigger the job was scheduled with.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

JobUnscheduled(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler when a IJobDetail is unscheduled.

ValueTask JobUnscheduled(IScheduler scheduler, TriggerKey triggerKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerKey TriggerKey

The trigger that was removed.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask
See Also

JobsPaused(IScheduler, string?, CancellationToken)

Called by the IScheduler when a group of IJobDetails has been paused.

ValueTask JobsPaused(IScheduler scheduler, string? jobGroup, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobGroup string

The job group, or null for all groups.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

A null jobGroup means every group, matching TriggersPaused(IScheduler, string?, CancellationToken). The scheduler's own pause-all path raises this once per group rather than once with no group, but a job store or a caller raising the event itself may report all groups that way.

JobsResumed(IScheduler, string?, CancellationToken)

Called by the IScheduler when a group of IJobDetails has been un-paused.

ValueTask JobsResumed(IScheduler scheduler, string? jobGroup, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobGroup string

The job group, or null for all groups.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

A null jobGroup means every group, matching TriggersResumed(IScheduler, string?, CancellationToken).

SchedulerError(IScheduler, SchedulerErrorContext, CancellationToken)

Called by the IScheduler when a serious error has occurred within the scheduler - such as repeated failures in the IJobStore, or the inability to instantiate a IJob instance when its ITrigger has fired.

ValueTask SchedulerError(IScheduler scheduler, SchedulerErrorContext errorContext, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

errorContext SchedulerErrorContext

What went wrong, and what it went wrong for.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

SchedulerErrorContext carries the trigger, job and firing the error was raised for wherever the scheduler knew them, so a listener can pause the offending trigger rather than read the keys out of the message text.

SchedulerInStandbyMode(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that it has move to standby mode.

ValueTask SchedulerInStandbyMode(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

SchedulerShutdown(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that it has Shutdown.

ValueTask SchedulerShutdown(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

SchedulerShuttingDown(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that it has begun the shutdown sequence.

ValueTask SchedulerShuttingDown(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

SchedulerStarted(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that it has started.

ValueTask SchedulerStarted(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

SchedulerStarting(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that it is starting.

ValueTask SchedulerStarting(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

SchedulingDataCleared(IScheduler, CancellationToken)

Called by the IScheduler to inform the listener that all jobs, triggers and calendars were deleted.

ValueTask SchedulingDataCleared(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

TriggerFinalized(IScheduler, ITrigger, CancellationToken)

Called by the IScheduler when a ITrigger has reached the condition in which it will never fire again.

ValueTask TriggerFinalized(IScheduler scheduler, ITrigger trigger, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

trigger ITrigger

The trigger that will never fire again.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

TriggerInError(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler when a ITrigger has moved into the Error state and will not fire again until it is reset with ResetTriggerFromErrorState(TriggerKey, CancellationToken).

ValueTask TriggerInError(IScheduler scheduler, TriggerKey triggerKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerKey TriggerKey

The trigger that was parked in the error state.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

This says what changed, not why. Where a cause exists it arrives separately through SchedulerError(IScheduler, SchedulerErrorContext, CancellationToken) — as a JobInstantiationException, for a job that could not be built. Some transitions have no scheduler-side cause at all: the job store also parks a trigger here when it cannot load the job's type or read the job back.

The default implementation does nothing.

TriggerPaused(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler a ITriggers has been paused.

ValueTask TriggerPaused(IScheduler scheduler, TriggerKey triggerKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerKey TriggerKey

The trigger that was paused.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

TriggerResumed(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler when a ITrigger has been un-paused.

ValueTask TriggerResumed(IScheduler scheduler, TriggerKey triggerKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerKey TriggerKey

The trigger that was resumed.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

TriggersInError(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when every ITrigger of a job has moved into the Error state, which is what a failure to instantiate the job leads to.

ValueTask TriggersInError(IScheduler scheduler, JobKey jobKey, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

jobKey JobKey

The job whose triggers were parked in the error state.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

Keyed by job rather than by trigger because that is the shape of the underlying operation — the persistent store updates the job's triggers in one statement and never enumerates them. Call GetTriggersOfJob(IScheduler, JobKey, CancellationToken) if the individual keys matter.

The default implementation does nothing.

TriggersPaused(IScheduler, string?, CancellationToken)

Called by the IScheduler a group of ITriggers has been paused.

ValueTask TriggersPaused(IScheduler scheduler, string? triggerGroup, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerGroup string

The trigger group, or null for all groups.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

A null triggerGroup means every group.

TriggersResumed(IScheduler, string?, CancellationToken)

Called by the IScheduler when a group of ITriggers has been un-paused.

ValueTask TriggersResumed(IScheduler scheduler, string? triggerGroup, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

triggerGroup string

The trigger group, or null for all groups.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

A null triggerGroup means every group.

See Also