Path: redb-route/redb.Route.Quartz/QuartzConsumerRegistry.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Quartz/QuartzConsumerRegistry.cs ---- using System.Collections.Concurrent; using Quartz; namespace redb.Route.Quartz; /// /// The running Quartz consumers of this process, by the job they claimed on their scheduler — the key Quartz fires by. /// One job key, one consumer per scheduler: refuses a second claimant, so two routes never /// share (and silently replace) one schedule. The same key on another node of a cluster is not a claimant here — /// it is that node's own consumer of the same schedule. /// internal static class QuartzConsumerRegistry { private static readonly ConcurrentDictionary Consumers = new(StringComparer.Ordinal); /// The registry key of on (this process's instance of it). internal static string KeyOf(IScheduler scheduler, JobKey jobKey) => $"{scheduler.SchedulerName}|{scheduler.SchedulerInstanceId}|{jobKey.Group}|{jobKey.Name}"; /// Claims for ; false with the current owner when taken. internal static bool TryRegister(string key, QuartzConsumerBase consumer, out QuartzConsumerBase owner) { owner = Consumers.GetOrAdd(key, consumer); return ReferenceEquals(owner, consumer); } /// Releases if holds it. internal static void Unregister(string key, QuartzConsumerBase consumer) => Consumers.TryRemove(new KeyValuePair(key, consumer)); /// The consumer that claimed on , or null. internal static QuartzConsumerBase? Get(IScheduler scheduler, JobKey jobKey) => Consumers.TryGetValue(KeyOf(scheduler, jobKey), out var consumer) ? consumer : null; }