Skip to content

Add Spring.Scheduling.Quartz4 for Quartz.NET 4.x - #399

Merged
lahma merged 5 commits into
mainfrom
4x/quartz4
Nov 5, 2026
Merged

lahma merged 5 commits into
mainfrom
4x/quartz4

Conversation

@lahma

@lahma lahma commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Part of #388: Spring.Scheduling.Quartz4, a new package for Quartz.NET 4.x (4.7.2), shipped alongside Spring.Scheduling.Quartz3, which becomes maintenance-only. The namespace is the same, Spring.Scheduling.Quartz.

The package targets net10.0 only, the only target Quartz 4 supports. It references Quartz 4.7.2 through VersionOverride, so Directory.Packages.props keeps Quartz3 on 3.22.9.

This PR doesn't include two pieces:

  • job-store participation in Spring-managed transactions, which builds on a Quartz.NET 4.8 enlistment hook that is in progress upstream;
  • the SQL Server integration tests and the example.

Both follow once that hook ships, and the README has a placeholder paragraph for the first.

Sources

The types shared with Quartz3 are compiled by link, with a QUARTZ4 define. Three Quartz3 files (QuartzJobObject, DelegatingJob, MethodInvokingJob) gain #if QUARTZ4 blocks that keep the original line verbatim in #else; Quartz3's behaviour and tests are unchanged.

These have Quartz4-only files:

  • SchedulerFactoryObject, SchedulerAccessor, SchedulerAccessorObject;
  • JobDetailObject, the trigger objects and MethodInvokingJobDetailFactoryObject;
  • AdaptableJobFactory, SpringObjectJobFactory, LocalTaskExecutorThreadPool, SpringDbProviderAdapter.

Design (decided on #388)

  • Building the scheduler.
    • SchedulerFactoryObject builds on QuartzSchedulerBuilder, keeps the StandaloneSchedulerFactory, and on dispose shuts the scheduler down first (honouring WaitForJobsToCompleteOnShutdown), then disposes the factory.
    • Configuration is applied in order: the QuartzProperties bag, then typed properties (SchedulerName, InstanceId, MaxConcurrency, MisfireThreshold, TablePrefix, Clustered, IdleWaitTime and more), then a ConfigureQuartz callback, so later layers win.
    • For components, Quartz's first registration wins: an explicitly configured JobFactory, TaskExecutor or DbProvider beats the callback, and the default job factory is registered after the callback so the callback can replace it.
  • Scheduler registry. Spring keeps its own registry of exposed schedulers, replacing SchedulerRepository.Instance. SchedulerFactoryType is gone, and a protected virtual CreateScheduler(builder) hook takes its place.
  • Jobs.
    • IJobFactory uses JobScope: the factory disposes only the job instances it created.
    • IThreadPool runs over Spring's ITaskExecutor and waits for in-flight work on Drain and Shutdown.
    • QuartzJobObject.ExecuteInternal is now ValueTask ExecuteInternal(IJobExecutionContext, CancellationToken), which is source-breaking for subclasses and documented.
  • Job details. JobDetailObject implements IJobDetail itself, since JobDetailImpl is internal in 4.x. Its job type must be an IJob, and a non-IJob type is refused with a pointer to MethodInvokingJobDetailFactoryObject.
  • Triggers follow Quartz 4's API: keys default to the object name, and misfire handling is the typed 4.x enum (MisfireInstruction = "DoNothing" in XML). There are no Name/Group/JobName/JobGroup or misfire-name compatibility properties.
  • JobSchedulingDataLocations is dropped. Quartz 4's XML processor is internal and is reachable only through Quartz.Plugins; the README shows that route through ConfigureQuartz.
  • Persistent store. A Spring DbProvider supplies the connections, and QuartzDbProvider names Quartz's dialect (SystemDataSqlClient, Npgsql and so on). The store is configured with AcceptEnlistedTransactions ready for the transaction bridge.
  • One thread inside the transaction. SchedulerAccessor registers jobs and triggers synchronously inside its TransactionManager transaction. On net10, Spring's transaction state is thread-static, and awaiting Quartz would commit on another thread.
  • Logging. Quartz logs through Spring's LogManager.LoggerFactory when one is set.

Also in this PR

  • Spring.Scheduling.Quartz3 is marked maintenance-only in its README and package description.
  • BreakingChanges item 14.
  • The AGENTS.md architecture table and the root README list the new package.
  • .github/dependabot.yml ignores Quartz semver-major updates, so Quartz3 is never offered 4.x. Whether Dependabot keeps 4.x minor bumps on the VersionOverride can only be confirmed by its first Quartz PR.

Tests

  • Spring.Scheduling.Quartz4.Tests (net10.0): 173 tests, all passing. They cover:
    • the typed options reaching the built scheduler, including "5s"/"1m" from XML, and the precedence;
    • the job-factory precedence;
    • the registry and its collision error;
    • the job factory and thread pool;
    • triggers and job details;
    • the one-thread transaction registration;
    • start and shutdown;
    • a test that loads and runs the README's XML snippet.
  • Spring.Scheduling.Quartz3.Tests is unchanged: 150 tests on two TFMs.
  • Build: 0 warnings. The pack has one net10.0 group depending on Quartz 4.7.2, and package validation is off until the 4.0.0 baseline exists.

A spring-reviewer pass accepted the change. Its follow-ups are in the last commit:

  • the callback's job factory now beats the default one;
  • no process-wide TimeSpan? converter change;
  • the job type is cached;
  • nits.

BindByName for custom providers, which only matters for Oracle and was the same in Quartz3, is carried to the transaction-bridge PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk

lahma and others added 5 commits November 5, 2026 17:39
New package Spring.Scheduling.Quartz4, net10.0 only. Types that are the same as in Quartz3 are compiled from the Quartz3 sources by link with a QUARTZ4 define; the others are Quartz4-only files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…e solution and the pack list (packet Q4a)

Unit tests for the Quartz4 package, ported from the Quartz3 tests where they compile against Quartz 4 and rewritten against the new creation hook where they used SchedulerFactoryType: typed options, precedence, repository exposure, job factory, thread pool, misfire enums, job and trigger keys, JobDetailObject, one-thread registration under a transaction manager, start and shutdown with wait. Fixes found by the tests: Spring's time span converter for the nullable time span options, a null job type is refused, the driver delegate is chosen through a public helper.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…ep Dependabot's Quartz lines apart (packet Q4a)

AGENTS.md architecture rows and the VersionOverride note, BreakingChanges.txt item 14, the package list in README.md, the Quartz3 README and description, a Dependabot rule that keeps Quartz 3.x from moving to 4.x.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…packet Q4a)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…converter, cached JobType, nits (review follow-ups)

The default AdaptableJobFactory is registered after the ConfigureQuartz callback, so the callback's job factory wins when JobFactory is not set; an explicit JobFactory still wins over the callback. The time span options are set-only TimeSpan properties over nullable fields, and the static constructor that replaced the TimeSpan? converter is gone. JobDetailObject caches the Quartz JobType. The adapt message names Func<Task>, the start delay log placeholder is {StartDelay}, and a second Dispose is a no-op.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk
Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
@lahma
lahma merged commit e7a5c84 into main Nov 5, 2026
4 checks passed
@lahma
lahma deleted the 4x/quartz4 branch November 5, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant