Table of Contents

Class DashboardLiveEventsPlugin

Namespace
Quartz.Dashboard.Plugins
Assembly
Quartz.Dashboard.dll

Pushes a scheduler's events to the browsers watching it, which is what makes the dashboard's live view live.

public sealed class DashboardLiveEventsPlugin : ISchedulerPlugin, IJobListener, ITriggerListener, ISchedulerListener
Inheritance
DashboardLiveEventsPlugin
Implements
Inherited Members

Remarks

It is all three listener kinds at once because the live view draws all three: a job starting and finishing, a trigger firing and misfiring, and the scheduler's own lifecycle. Registered by AddQuartzDashboard against every scheduler in the container rather than named by a quartz.plugin.*.type key, and told its own scheduler's name when it is initialized — which is the SignalR group it broadcasts to.

Constructors

DashboardLiveEventsPlugin(IServiceProvider)

Takes the container the dashboard's SignalR hub is resolved from.

public DashboardLiveEventsPlugin(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

Remarks

A plugin is constructed by the container — this one is registered for every scheduler by AddQuartzDashboard — so it asks for what it needs the way any other component does. It used to read the container back out of scheduler.Context["Quartz.ServiceProvider"], which put Quartz's plumbing into the application's own map, and left the scheduler-context endpoint of the HTTP API answering 500 for every scheduler a container had built.

The clock is this scheduler's: a named scheduler is built through a provider that resolves its own parts, so a scheduler given a TimeProvider of its own stamps its misfires with it. An execution needs no clock — it carries the fire time the scheduler already recorded.

Properties

Name

The name this listener is registered and removed under.

public 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

Initialize(string, IScheduler, CancellationToken)

Called during creation of the IScheduler in order to give the ISchedulerPlugin a chance to Initialize.

public ValueTask Initialize(string pluginName, IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

pluginName string

The name by which the plugin is identified.

scheduler IScheduler

The scheduler to which the plugin is registered.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

At this point, the Scheduler's IJobStore is not yet

If you need direct access your plugin, you can have it explicitly put a reference to itself in the IScheduler's SchedulerContext as part of its Initialize(string, IScheduler, CancellationToken) method.

JobAdded(IScheduler, IJobDetail, CancellationToken)

Called by the IScheduler when a IJobDetail has been added.

public 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.

public 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

JobExecutionVetoed(IJobExecutionContext, CancellationToken)

Called by the IScheduler when a IJobDetail was about to be executed (an associated ITrigger has occurred), but a ITriggerListener vetoed it's execution.

public ValueTask JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The default implementation does nothing.

See Also

JobInterrupted(IScheduler, JobKey, CancellationToken)

Called by the IScheduler when a IJobDetail has been interrupted.

public 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.

public 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.

public 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.

public 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

JobToBeExecuted(IJobExecutionContext, CancellationToken)

Called by the IScheduler when a IJobDetail is about to be executed (an associated ITrigger has occurred).

This method will not be invoked if the execution of the Job was vetoed by a ITriggerListener.

public ValueTask JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The default implementation does nothing.

See Also

JobUnscheduled(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler when a IJobDetail is unscheduled.

public 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

JobWasExecuted(IJobExecutionContext, JobExecutionException?, CancellationToken)

Called by the IScheduler after a IJobDetail has been executed, and be for the associated IOperableTrigger's Triggered(ICalendar?) method has been called.

public ValueTask JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext
jobException JobExecutionException
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The default implementation does nothing.

JobsPaused(IScheduler, string?, CancellationToken)

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

public 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.

public 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.

public 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.

public 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.

public 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.

public 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.

public 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)

Nothing is pushed: a scheduler that is starting is an event, not a state it is in.

public ValueTask SchedulerStarting(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler
cancellationToken CancellationToken

Returns

ValueTask

Remarks

The state it will be in arrives a moment later as SchedulerStarted(IScheduler, CancellationToken), and pushing "starting" first only gave a browser a value that is not a SchedulerStatus to render in the meantime.

SchedulingDataCleared(IScheduler, CancellationToken)

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

public ValueTask SchedulingDataCleared(IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Shutdown(CancellationToken)

Called in order to inform the ISchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.

public ValueTask Shutdown(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask

Remarks

Does nothing unless the plugin says otherwise. Most plugins do all their work in Initialize(string, IScheduler, CancellationToken) — attaching a listener, registering a resolver — and have nothing to say at the two lifecycle moments; implement this only when there is something that cannot happen until the scheduler is running.

Start(CancellationToken)

Called when the associated IScheduler is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.

public ValueTask Start(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask

Remarks

Does nothing unless the plugin says otherwise. Most plugins do all their work in Initialize(string, IScheduler, CancellationToken) — attaching a listener, registering a resolver — and have nothing to say at the two lifecycle moments; implement this only when there is something that cannot happen until the scheduler is running.

TriggerComplete(ITrigger, IJobExecutionContext, SchedulerInstruction, CancellationToken)

Called by the IScheduler when a ITrigger has fired, it's associated IJobDetail has been executed, and it's Triggered(ICalendar?) method has been called.

public ValueTask TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that was fired.

context IJobExecutionContext

The IJobExecutionContext that was passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

triggerInstructionCode SchedulerInstruction

The result of the call on the ITrigger'sTriggered(ICalendar?) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The default implementation does nothing.

TriggerFinalized(IScheduler, ITrigger, CancellationToken)

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

public 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

TriggerFired(ITrigger, IJobExecutionContext, CancellationToken)

Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.

It is called before the VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken) method of this interface.

public ValueTask TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that has fired.

context IJobExecutionContext

The IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The default implementation does nothing.

TriggerMisfired(ITrigger, IScheduler, CancellationToken)

Called by the IScheduler when a ITrigger has misfired.

Consideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.

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

Parameters

trigger ITrigger

The ITrigger that has misfired.

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The scheduler is passed because a misfire is noticed outside any execution, so there is no IJobExecutionContext here to reach it through. It comes after the trigger, as the context does on every other notification in this interface.

The default implementation does nothing.

TriggerPaused(IScheduler, TriggerKey, CancellationToken)

Called by the IScheduler a ITriggers has been paused.

public 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.

public 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

TriggersPaused(IScheduler, string?, CancellationToken)

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

public 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.

public 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.

VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken)

Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.

It is called after the TriggerFired(ITrigger, IJobExecutionContext, CancellationToken) method of this interface. If the implementation vetoes the execution (via returning true), the job's execute method will not be called.

public ValueTask<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that has fired.

context IJobExecutionContext

The IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<bool>

Returns true if job execution should be vetoed, false otherwise.

Remarks

The default implementation vetoes nothing.