Table of Contents

Class SchedulerRepository

Namespace
Quartz.Impl
Assembly
Quartz.dll

Holds references to Scheduler instances - ensuring uniqueness, and preventing garbage collection, and allowing lookups by name.

public sealed class SchedulerRepository : ISchedulerRepository
Inheritance
SchedulerRepository
Implements
Inherited Members

Remarks

A repository is owned by the container it is registered in; there is no process-wide instance. Resolve ISchedulerRepository to reach the one belonging to a scheduler, which is what makes two sets of schedulers in one process independent of each other.

Schedulers are indexed by name. Multiple schedulers with the same name but different instance IDs can coexist (e.g., remote proxies to different cluster nodes). Pass an instance ID to Lookup(string, string?) to disambiguate between them.

A scheduler that has shut down is dropped as soon as a read notices it. A scheduler unbinds itself from the repository its own container owns, and from no other, so one bound here by hand — the way a standalone scheduler is made visible to a dashboard or the HTTP API — would otherwise stay listed as a live scheduler for the rest of the process.

Methods

Bind(IScheduler, string?)

Binds a scheduler to the registry.

public void Bind(IScheduler scheduler, string? instanceId = null)

Parameters

scheduler IScheduler

The scheduler to bind.

instanceId string

The instance ID to index the scheduler under. When null, SchedulerInstanceId supplies it; pass it explicitly for a remote scheduler, where reading that property may cost a network call.

Remarks

Without an explicit instance ID this reads SchedulerInstanceId, which is always available for a local scheduler. For a remote one (e.g., HttpScheduler) reading it may cost a network call, so pass the instance ID instead. If it cannot be resolved at all, the scheduler name is used as a fallback, preserving single-scheduler-per-name semantics.

Lookup(string, string?)

Looks up a scheduler by name, and by instance ID when one is given.

public IScheduler? Lookup(string schedulerName, string? instanceId = null)

Parameters

schedulerName string

The name of the scheduler to look up.

instanceId string

The instance ID to disambiguate by. When null, the first scheduler registered under the name is returned.

Returns

IScheduler

Remarks

Schedulers registered under this name that have shut down are evicted rather than returned.

LookupAll()

Returns all registered schedulers.

public List<IScheduler> LookupAll()

Returns

List<IScheduler>

Remarks

Schedulers that have shut down are evicted rather than returned. This is the read that sweeps the whole repository, so it is what a dashboard or the HTTP API listing schedulers cleans up with.

LookupByName(string)

Returns all schedulers with the given name.

public List<IScheduler> LookupByName(string schedulerName)

Parameters

schedulerName string

Returns

List<IScheduler>

Remarks

Schedulers registered under this name that have shut down are evicted rather than returned.

Remove(string, string?)

Removes a scheduler from the registry.

public bool Remove(string schedulerName, string? instanceId = null)

Parameters

schedulerName string

The name of the scheduler to remove.

instanceId string

The instance ID of the scheduler to remove. When null, the first scheduler registered under the name is removed.

Returns

bool

true if a scheduler was found and removed.