Skip to content

Commit

Permalink
Quartz.NET 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Oct 1, 2020
1 parent 906e87e commit 57cd083
Show file tree
Hide file tree
Showing 28 changed files with 374 additions and 198 deletions.
1 change: 1 addition & 0 deletions Quartz.sln.DotSettings
Expand Up @@ -59,6 +59,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002EDaemon_002ESettings_002EMigration_002ESwaWarningsModeSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Expand Up @@ -2,7 +2,7 @@

[http://www.quartz-scheduler.net](http://www.quartz-scheduler.net)

## Release 3.2.0, Aug xx 2020
## Release 3.2.0, Oct 1 2020

This is a release that focuses on restructuring some packages that warrants for a minor version number increment.

Expand All @@ -25,6 +25,7 @@ There's also important fix for SQL Server where varying text parameter sizes cau
* SqlServer AdoJobStore SqlParameter without text size generates pressure on server (#939)
* DbProvider initialization logic should also read quartz.config (#951)
* LoggingJobHistoryPlugin and LoggingTriggerHistoryPlugin names are null with IoC configuration (#926)
* Improve options pattern to allow better custom configuration story (#955)

* NEW FEATURE

Expand Down
36 changes: 36 additions & 0 deletions docs/_posts/2020-10-01-quartznet-3.2-released.md
@@ -0,0 +1,36 @@
---
title : Quartz.NET 3.2 Released
layout: default
tags : [releases]
---

This release concentrates on tweaking the DI story and fixing some found dependency issues.

Now Quartz no longer has hard dependency on Microsoft.Data.SqlClient, you need to add that dependency to your project
if you are using Microsoft SQL Server as backing store for your project. Now requirement is in line with other providers/drivers.

There's also important fix for SQL Server where varying text parameter sizes caused query plan pollution.

* BREAKING CHANGES

* Remove dependency on Microsoft.Data.SqlClient (#912)
* LogContext moved from Quartz namespace to Quartz.Logging namespace (#915)
* For Full Framework, System.Data.SqlClient is again the default provider, Microsoft.Data can be used via provider MicrosoftDataSqlClient (#916)

* FIXES

* Revert change in 3.1: CronExpression/cron trigger throwing NotImplementedException when calculating final fire time (#905)
* Use 2.1 as the minimum version for the .NET Platform Extensions (#923)
* ServiceCollection.AddQuartz() should register default ITypeLoadHelper if none supplied (#924)
* SqlServer AdoJobStore SqlParameter without text size generates pressure on server (#939)
* DbProvider initialization logic should also read quartz.config (#951)
* LoggingJobHistoryPlugin and LoggingTriggerHistoryPlugin names are null with IoC configuration (#926)
* Improve options pattern to allow better custom configuration story (#955)

* NEW FEATURE

* Introduce separate Quartz.Extensions.Hosting (#911)
* You can now schedule job and trigger in MS DI integration with single .ScheduleJob call (#943)
* Support adding calendars to MS DI via AddCalendar<T> (#945)

<Download />
10 changes: 10 additions & 0 deletions src/Quartz.Examples.AspNetCore/SampleOptions.cs
@@ -0,0 +1,10 @@
namespace Quartz.Examples.AspNetCore
{
/// <summary>
/// Example of user defined options.
/// </summary>
public class SampleOptions
{
public string CronSchedule { get; set; } = "";
}
}
21 changes: 21 additions & 0 deletions src/Quartz.Examples.AspNetCore/Startup.cs
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

using OpenTelemetry.Trace;

Expand Down Expand Up @@ -183,6 +184,26 @@ public void ConfigureServices(IServiceCollection services)
});
*/
});

// we can use options pattern to support hooking your own configuration with Quartz's
// because we don't use service registration api, we need to manally ensure the job is present in DI
services.AddTransient<ExampleJob>();

services.Configure<SampleOptions>(Configuration.GetSection("Sample"));
services.AddOptions<QuartzOptions>()
.Configure<IOptions<SampleOptions>>((options, dep) =>
{
if (!string.IsNullOrWhiteSpace(dep.Value.CronSchedule))
{
var jobKey = new JobKey("options-custom-job", "custom");
options.AddJob<ExampleJob>(j => j.WithIdentity(jobKey));
options.AddTrigger(trigger => trigger
.WithIdentity("options-custom-trigger", "custom")
.ForJob(jobKey)
.WithCronSchedule(dep.Value.CronSchedule));
}
});


// ASP.NET Core hosting
services.AddQuartzServer(options =>
Expand Down
3 changes: 3 additions & 0 deletions src/Quartz.Examples.AspNetCore/appsettings.json
Expand Up @@ -9,5 +9,8 @@
"AllowedHosts": "*",
"Quartz": {
"quartz.scheduler.instanceName": "Quartz ASP.NET Core Sample Scheduler"
},
"Sample": {
"CronSchedule": "0/25 * * * * ?"
}
}
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

using Quartz.Spi;
using Quartz.Xml;
Expand All @@ -14,19 +12,21 @@ namespace Quartz
/// </summary>
internal class ContainerConfigurationProcessor : XMLSchedulingDataProcessor
{
private readonly IServiceProvider serviceProvider;
private readonly IOptions<QuartzOptions> options;

public ContainerConfigurationProcessor(IServiceProvider serviceProvider)
: base(serviceProvider.GetRequiredService<ITypeLoadHelper>())
public ContainerConfigurationProcessor(
ITypeLoadHelper typeLoadHelper,
IOptions<QuartzOptions> options)
: base(typeLoadHelper)
{
this.serviceProvider = serviceProvider;
var options = serviceProvider.GetService<QuartzSchedulingOptions>() ?? new QuartzSchedulingOptions();
OverWriteExistingData = options.OverWriteExistingData;
IgnoreDuplicates = options.IgnoreDuplicates;
ScheduleTriggerRelativeToReplacedTrigger = options.ScheduleTriggerRelativeToReplacedTrigger;
this.options = options;
}

protected override IReadOnlyList<IJobDetail> LoadedJobs => serviceProvider.GetServices<IJobDetail>().ToList();
protected override IReadOnlyList<ITrigger> LoadedTriggers => serviceProvider.GetServices<ITrigger>().ToList();
public override bool OverWriteExistingData => options.Value.Scheduling.OverWriteExistingData;
public override bool IgnoreDuplicates => options.Value.Scheduling.IgnoreDuplicates;
public override bool ScheduleTriggerRelativeToReplacedTrigger => options.Value.Scheduling.ScheduleTriggerRelativeToReplacedTrigger;

protected override IReadOnlyList<IJobDetail> LoadedJobs => options.Value.JobDetails;
protected override IReadOnlyList<ITrigger> LoadedTriggers => options.Value.Triggers;
}
}

This file was deleted.

Expand Up @@ -2,7 +2,7 @@

namespace Quartz
{
public interface IServiceCollectionTriggerConfigurator
public interface ITriggerConfigurator
{
/// <summary>
/// Use a <see cref="TriggerKey" /> with the given name and default group to
Expand All @@ -16,7 +16,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="TriggerKey" />
/// <seealso cref="ITrigger.Key" />
IServiceCollectionTriggerConfigurator WithIdentity(string name);
ITriggerConfigurator WithIdentity(string name);

/// <summary>
/// Use a TriggerKey with the given name and group to
Expand All @@ -31,7 +31,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="TriggerKey" />
/// <seealso cref="ITrigger.Key" />
IServiceCollectionTriggerConfigurator WithIdentity(string name, string group);
ITriggerConfigurator WithIdentity(string name, string group);

/// <summary>
/// Use the given TriggerKey to identify the Trigger.
Expand All @@ -44,7 +44,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="TriggerKey" />
/// <seealso cref="ITrigger.Key" />
IServiceCollectionTriggerConfigurator WithIdentity(TriggerKey key);
ITriggerConfigurator WithIdentity(TriggerKey key);

/// <summary>
/// Set the given (human-meaningful) description of the Trigger.
Expand All @@ -54,7 +54,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <param name="description">the description for the Trigger</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.Description" />
IServiceCollectionTriggerConfigurator WithDescription(string? description);
ITriggerConfigurator WithDescription(string? description);

/// <summary>
/// Set the Trigger's priority. When more than one Trigger have the same
Expand All @@ -67,7 +67,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="TriggerConstants.DefaultPriority" />
/// <seealso cref="ITrigger.Priority" />
IServiceCollectionTriggerConfigurator WithPriority(int priority);
ITriggerConfigurator WithPriority(int priority);

/// <summary>
/// Set the name of the <see cref="ICalendar" /> that should be applied to this
Expand All @@ -79,7 +79,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ICalendar" />
/// <seealso cref="ITrigger.CalendarName" />
IServiceCollectionTriggerConfigurator ModifiedByCalendar(string? calendarName);
ITriggerConfigurator ModifiedByCalendar(string? calendarName);

/// <summary>
/// Set the time the Trigger should start at - the trigger may or may
Expand All @@ -93,7 +93,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.StartTimeUtc" />
/// <seealso cref="DateBuilder" />
IServiceCollectionTriggerConfigurator StartAt(DateTimeOffset startTimeUtc);
ITriggerConfigurator StartAt(DateTimeOffset startTimeUtc);

/// <summary>
/// Set the time the Trigger should start at to the current moment -
Expand All @@ -104,7 +104,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.StartTimeUtc" />
IServiceCollectionTriggerConfigurator StartNow();
ITriggerConfigurator StartNow();

/// <summary>
/// Set the time at which the Trigger will no longer fire - even if it's
Expand All @@ -116,7 +116,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.EndTimeUtc" />
/// <seealso cref="DateBuilder" />
IServiceCollectionTriggerConfigurator EndAt(DateTimeOffset? endTimeUtc);
ITriggerConfigurator EndAt(DateTimeOffset? endTimeUtc);

/// <summary>
/// Set the <see cref="IScheduleBuilder" /> that will be used to define the
Expand All @@ -132,7 +132,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <seealso cref="SimpleScheduleBuilder" />
/// <seealso cref="CronScheduleBuilder" />
/// <seealso cref="CalendarIntervalScheduleBuilder" />
IServiceCollectionTriggerConfigurator WithSchedule(IScheduleBuilder scheduleBuilder);
ITriggerConfigurator WithSchedule(IScheduleBuilder scheduleBuilder);

/// <summary>
/// Set the identity of the Job which should be fired by the produced
Expand All @@ -143,7 +143,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <param name="jobKey">the identity of the Job to fire.</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobKey" />
IServiceCollectionTriggerConfigurator ForJob(JobKey jobKey);
ITriggerConfigurator ForJob(JobKey jobKey);

/// <summary>
/// Set the identity of the Job which should be fired by the produced
Expand All @@ -155,7 +155,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <param name="jobName">the name of the job (in default group) to fire.</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobKey" />
IServiceCollectionTriggerConfigurator ForJob(string jobName);
ITriggerConfigurator ForJob(string jobName);

/// <summary>
/// Set the identity of the Job which should be fired by the produced
Expand All @@ -168,7 +168,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <param name="jobGroup">the group of the job to fire.</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobKey" />
IServiceCollectionTriggerConfigurator ForJob(string jobName, string jobGroup);
ITriggerConfigurator ForJob(string jobName, string jobGroup);

/// <summary>
/// Set the identity of the Job which should be fired by the produced
Expand All @@ -179,7 +179,7 @@ public interface IServiceCollectionTriggerConfigurator
/// <param name="jobDetail">the Job to fire.</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobKey" />
IServiceCollectionTriggerConfigurator ForJob(IJobDetail jobDetail);
ITriggerConfigurator ForJob(IJobDetail jobDetail);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -188,7 +188,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(JobDataMap newJobDataMap);
ITriggerConfigurator UsingJobData(JobDataMap newJobDataMap);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -197,7 +197,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, string value);
ITriggerConfigurator UsingJobData(string key, string value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -206,7 +206,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, int value);
ITriggerConfigurator UsingJobData(string key, int value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -215,7 +215,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, long value);
ITriggerConfigurator UsingJobData(string key, long value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -224,7 +224,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, float value);
ITriggerConfigurator UsingJobData(string key, float value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -233,7 +233,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, double value);
ITriggerConfigurator UsingJobData(string key, double value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -242,7 +242,7 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, decimal value);
ITriggerConfigurator UsingJobData(string key, decimal value);

/// <summary>
/// Add the given key-value pair to the Trigger's <see cref="JobDataMap" />.
Expand All @@ -251,6 +251,6 @@ public interface IServiceCollectionTriggerConfigurator
/// </remarks>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="ITrigger.JobDataMap" />
IServiceCollectionTriggerConfigurator UsingJobData(string key, bool value);
ITriggerConfigurator UsingJobData(string key, bool value);
}
}
6 changes: 6 additions & 0 deletions src/Quartz.Extensions.DependencyInjection/JobConfigurator.cs
@@ -0,0 +1,6 @@
namespace Quartz
{
internal class JobConfigurator : JobBuilder, IJobConfigurator
{
}
}

0 comments on commit 57cd083

Please sign in to comment.