https://github.com/sugiruu/hosting.extensions.quartz
Easily integrate .NET Core's Host with Quartz.NET
https://github.com/sugiruu/hosting.extensions.quartz
Last synced: 12 days ago
JSON representation
Easily integrate .NET Core's Host with Quartz.NET
- Host: GitHub
- URL: https://github.com/sugiruu/hosting.extensions.quartz
- Owner: sugiruu
- License: apache-2.0
- Created: 2019-05-28T19:08:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T22:36:34.000Z (almost 5 years ago)
- Last Synced: 2025-04-15T00:48:01.864Z (12 days ago)
- Language: C#
- Homepage: https://www.nuget.org/packages/Hosting.Extensions.Quartz
- Size: 28.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hosting.Extensions.Quartz
[](https://ci.appveyor.com/project/skiptirengu/hosting-extensions-quartz/branch/master)
Easily integrate .NET Core's Host with Quartz
## Usage
Check out the [working example](./examples).
To enable the Quartz integration, simply call one of the three `UseQuartz()` extension methods on your HostBuilder.
```c#
new HostBuilder().UseQuartz((context, provider, scheduler) =>
{
// You can further configure the scheduler instance here, like
// add job listeners, trigger listeners, etc.
// DO NOT call the Start method here as it will be automatically
// invoked by the hosted service once it has started.
scheduler.ListenerManager.AddJobListener(
new JobChainingJobListener("TestListener"), KeyMatcher.KeyEquals(new JobKey("DummyJob"))
);
})
```To change Quartz options, add a section to your `appsettings.json` file, or use the `UserQuartz()` method.
```json
{
"Quartz": {
"quartz.threadPool.type": "Quartz.Simpl.SimpleThreadPool, Quartz",
"quartz.threadPool.threadCount": 5,
"quartz.threadPool.threadPriority": "Normal",
"quartz.jobStore.type": "Quartz.Simpl.RAMJobStore, Quartz",
"quartz.jobStore.misfireThreshold": 6000
}
}
```or
```c#
new HostBuilder().UseQuartz((context, config) =>
{
config.Set("quartz.threadPool.threadCount", "2");
})
```To schedule a new job, call the extension method `AddJobService()` on a `IServiceCollection` instance.
```c#
new HostBuilder().ConfigureServices((services) =>
{
services.AddJobService((job, trigger) =>
{
job.WithIdentity("job1").WithDescription("Simple job");
trigger.StartNow().WithSimpleSchedule((x) => x.WithIntervalInSeconds(5).RepeatForever());
});
services.AddJobService((job, trigger) =>
{
job.WithIdentity("job2").WithDescription("Simple job");
trigger.StartNow().WithSimpleSchedule((x) => x.WithIntervalInSeconds(60).RepeatForever());
});
})
```## License
Licensed under the [Apache License 2.0](./LICENSE) license.