Quartz.NET tutorial sample: move to Quartz.NET 4.1.0 - #2221
Merged
vladimir-pecanac-main merged 2 commits intoSep 17, 2026
Merged
vladimir-pecanac-main merged 2 commits into
vladimir-pecanac-main merged 2 commits into
Conversation
Quartz.NET 4 changes the job signature, merges three packages into one and removes the interval shorthand, so the sample no longer compiles as written. - Quartz 3.19.1 to 4.1.0. Quartz.Extensions.Hosting and Quartz.Serialization.Json are dropped: both publish empty forwarding packages on 4.1.0, and hosting, dependency injection and the System.Text.Json serializer are in Quartz itself. - Microsoft.Data.SqlClient 6.1.1 to 7.0.3, the newest stable. - IJob.Execute moves to ValueTask plus a CancellationToken, with the default on the token so both existing tests keep compiling unchanged. - WithIntervalInSeconds(5) becomes WithInterval(TimeSpan.FromSeconds(5)). - UseNewtonsoftJsonSerializer() becomes UseSystemTextJsonSerializer(). - ScheduleJob passes ScheduleJobOptions.Replacing. With a persistent store the job definition is already in the database on the second start, and without this the sample throws ObjectAlreadyExistsException before the scheduler runs. Checked against SQL Server 2022 in Docker: one start on an empty database, then two restarts, all clean. dotnet build -c Release: 0 warnings, 0 errors. dotnet test: 2 of 2 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quartz.NET 4.1.0 pass on the
dotnet-client-libraries/Quartz.NETsample, which backs the "Quartz.NET in C#: How to Schedule Jobs" article.Quartz.NET 4 changes the job signature, merges three packages into the main one and removes the interval shorthand, so the sample does not compile as written.
Three files, five hunks, one folder.
Quartz.NET.csproj: Quartz 3.19.1 to 4.1.0;Quartz.Extensions.HostingandQuartz.Serialization.Jsondropped (both publish empty forwarding packages on 4.1.0, with hosting, DI and the System.Text.Json serializer insideQuartz);Microsoft.Data.SqlClient6.1.1 to 7.0.3, the newest stable.BackgroundJob.cs:IJob.Executemoves toValueTaskplus aCancellationToken. The default on the token keeps both existing tests compiling unchanged, soTests/is untouched.Program.cs:WithIntervalInSeconds(5)becomesWithInterval(TimeSpan.FromSeconds(5));UseNewtonsoftJsonSerializer()becomesUseSystemTextJsonSerializer();ScheduleJobpassesScheduleJobOptions.Replacing.Why the third
Program.cshunk. With a persistent store the job definition is already in the database on the second start, so the old line throwsObjectAlreadyExistsExceptionbefore the scheduler runs. Checked against SQL Server 2022 in Docker with thev4.1.0schema script: one start on an empty database (job persisted, triggerACQUIRED), one restart without the option (crash), two restarts with it (clean).dotnet build -c Release: 0 warnings, 0 errors.dotnet test: 2 of 2 passed. SDK 10.0.302, runtime 10.0.10.