Autofac.Extras.Quartz 10.0.0

dotnet add package Autofac.Extras.Quartz --version 10.0.0
                    
NuGet\Install-Package Autofac.Extras.Quartz -Version 10.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Autofac.Extras.Quartz" Version="10.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Autofac.Extras.Quartz" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Autofac.Extras.Quartz" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Autofac.Extras.Quartz --version 10.0.0
                    
#r "nuget: Autofac.Extras.Quartz, 10.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Autofac.Extras.Quartz&version=10.0.0
                    
Install Autofac.Extras.Quartz as a Cake Addin
#tool nuget:?package=Autofac.Extras.Quartz&version=10.0.0
                    
Install Autofac.Extras.Quartz as a Cake Tool

Autofac.Extras.Quartz

Autofac integration package for Quartz.Net.

Autofac.Extras.Quartz creates nested litefime scope for each Quartz Job. Nested scope is disposed after job execution has been completed.

This allows to have single instance per job execution as well as deterministic disposal of resources.

Install package via Nuget: install-package Autofac.Extras.Quartz

Build status

Stable Pre-release
Build Master branch Development branch
NuGet NuGet NuGet
CodeCov codecov codecov

Usage example

Autofac configuration for Quartz includes two steps:

  1. Scheduler registration
  2. Job registration

Scheduler registration

QuartzAutofacFactoryModule registers custom ISchedulerFactory and default instance of IScheduler in Autofac container. Both factory and schedulere are registered as singletones. Note: Is is important to resolve IScheduler from container, rather than using default one to get jobs resolved by Autofac.

Optionally custom Quartz configuration can be passed using ConfigurationProvider property. Provider is callback which returns settings using NameValueCollection.

Job scope configuration

Starting with version 7 QuartzAutofacFactoryModule provides a way to customize lifetime scope configuration for job. This can be done via JobScopeConfigurator parameter.

cb.Register(_ => new ScopedDependency("global"))
    .AsImplementedInterfaces()
    .SingleInstance();

cb.RegisterModule(new QuartzAutofacFactoryModule {
    JobScopeConfigurator = (builder, jobScopeTag) => {
        // override dependency for job scope
        builder.Register(_ => new ScopedDependency("job-local "+ DateTime.UtcNow.ToLongTimeString()))
            .AsImplementedInterfaces()
            .InstancePerMatchingLifetimeScope(jobScopeTag);

    }
});

See src/Samples/Shared/Bootstrap.cs for details.

Job registration

QuartzAutofacJobsModule scans given assemblies and registers all non-abstract implementors of IJob interface as transient instances.

internal static ContainerBuilder ConfigureContainer(ContainerBuilder cb)
{
	// 1) Register IScheduler
	cb.RegisterModule(new QuartzAutofacFactoryModule()); 
	// 2) Register jobs
	cb.RegisterModule(new QuartzAutofacJobsModule(typeof (CleanupExpiredAnnouncemetsJob).Assembly));
}

Starting Quartz

Make sure to start the scheduler after it was resolved from Autofac. E.g.

var scheduler = _container.Resolve<IScheduler>();
scheduler.Start();

Sample projects

TopShelf-based sample was removed since Topshelf.Quartz is not compatible with Quartz 3 as af now.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on Autofac.Extras.Quartz:

Package Downloads
Lauener.Core.Triggers

A easy to use Quartz implementation

TripleSix.Core

Package Description

HwApp.Quartz

HwApp Quartz & Quartzmin

SyWaterStandardLibrary

舜禹框架Core 3.0

Cogito.Quartz.Autofac

Provides utilites and extensions for Quartz and Autofac.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Autofac.Extras.Quartz:

Repository Stars
PlexRipper/PlexRipper
A cross-platform Plex media downloader that seamlessly adds media from other Plex servers to your own!
Version Downloads Last updated
10.0.0 225,873 3/7/2024
10.0.0-alpha0007 125 3/5/2024
10.0.0-alpha0006 141 3/4/2024
9.0.0 221,083 3/27/2023
8.2.0 69,936 1/30/2023
8.2.0-alpha0001 210 1/30/2023
8.1.0 2,463 1/24/2023
8.1.0-alpha0003 235 12/22/2022
8.1.0-alpha0002 213 12/22/2022
8.0.0 148,658 6/3/2022
7.4.0-alpha0007 278 6/2/2022
7.4.0-alpha0005 10,879 5/17/2022
7.4.0-alpha0002 224 5/8/2022
7.3.0 192,809 10/28/2021
7.3.0-alpha0009 315 10/28/2021
7.2.0 50,410 8/2/2021
7.2.0-alpha0006 327 8/1/2021
7.1.0 67,772 4/25/2021
7.1.0-alpha0011 338 8/1/2021
7.1.0-alpha0010 372 8/1/2021
7.1.0-alpha0009 389 8/1/2021
7.1.0-alpha0008 338 6/20/2021
7.1.0-alpha0006 332 4/30/2021
7.1.0-alpha0004 339 4/24/2021
7.1.0-alpha0003 379 4/24/2021
7.1.0-alpha0002 328 4/19/2021
7.1.0-alpha0001 318 4/19/2021
7.0.0 216,069 2/16/2021
7.0.0-beta0001 334 2/14/2021
7.0.0-alpha0024 353 2/14/2021
7.0.0-alpha0023 357 2/9/2021
6.3.0-alpha0001 349 2/9/2021
6.2.0 15,101 1/29/2021
6.2.0-beta0001 341 1/29/2021
6.2.0-alpha0008 353 1/28/2021
6.2.0-alpha0001 472 1/10/2021
6.1.0 17,852 1/10/2021
6.1.0-beta0001 387 1/4/2021
6.0.1 47,150 10/21/2020
6.0.1-beta0001 493 10/21/2020
6.0.0 73,466 10/9/2020
6.0.0-beta0001 454 10/9/2020
6.0.0-alpha0041 466 10/7/2020
6.0.0-alpha0039 496 10/7/2020
5.4.0 41,770 10/7/2020
5.4.0-beta0001 461 10/4/2020
5.4.0-alpha0007 453 10/4/2020
5.4.0-alpha0001 682 8/6/2020
5.3.0 40,962 8/6/2020
5.3.0-beta0001 480 8/6/2020
5.3.0-alpha0009 489 8/6/2020
5.3.0-alpha0008 546 7/27/2020
5.3.0-alpha0007 558 7/8/2020
5.3.0-alpha0001 1,095 5/19/2020
5.2.0 112,933 5/19/2020
5.2.0-beta0001 521 5/19/2020
5.2.0-alpha0023 515 5/19/2020
5.2.0-alpha0021 794 2/17/2020
5.1.0 164,397 2/17/2020
5.1.0-alpha0015 514 2/17/2020
5.1.0-alpha0014 587 2/8/2020
5.1.0-alpha0005 594 1/30/2020
5.0.0 27,902 1/30/2020
5.0.0-beta0001 602 1/30/2020
5.0.0-alpha0064 527 1/30/2020
4.7.0-alpha0013 3,264 1/29/2020
4.7.0-alpha0009 550 1/27/2020
4.7.0-alpha0007 2,000 11/18/2019
4.7.0-alpha0006 547 11/17/2019
4.7.0-alpha0005 583 11/8/2019
4.7.0-alpha0004 1,202 9/2/2019
4.6.0 229,296 9/2/2019
4.6.0-beta0001 604 9/1/2019
4.6.0-alpha0036 591 9/1/2019
4.6.0-alpha0034 580 9/1/2019
4.6.0-alpha0033 570 9/1/2019
4.6.0-alpha0028 648 7/13/2019
4.6.0-alpha0026 604 7/13/2019
4.6.0-alpha0024 584 7/6/2019
4.6.0-alpha0022 587 7/6/2019
4.6.0-alpha0018 589 7/6/2019
4.6.0-alpha0008 736 5/8/2019
4.6.0-alpha0005 605 5/8/2019
4.6.0-alpha0003 637 5/8/2019
4.6.0-alpha0001 765 3/10/2019
4.5.1 177,699 5/8/2019
4.5.1-beta0001 637 5/8/2019
4.5.0 110,243 3/9/2019
4.5.0-beta0001 640 3/9/2019
4.5.0-alpha0008 611 3/9/2019
4.5.0-alpha0007 640 3/8/2019
4.5.0-alpha0005 667 2/25/2019
4.5.0-alpha0003 893 2/11/2019
4.5.0-alpha0002 715 1/28/2019
4.5.0-alpha0001 732 1/27/2019
4.4.0 109,656 1/27/2019
4.4.0-beta0001 758 1/27/2019
4.4.0-alpha0014 1,115 9/29/2018
4.4.0-alpha0013 829 9/29/2018
4.4.0-alpha0012 812 9/29/2018
4.4.0-alpha0002 892 9/23/2018
4.4.0-alpha0001 826 9/19/2018
4.3.0 157,828 9/29/2018
4.3.0-beta0001 864 9/26/2018
4.3.0-alpha0008 1,554 7/11/2018
4.3.0-alpha0007 1,119 7/7/2018
4.3.0-alpha0006 1,115 7/7/2018
4.3.0-alpha0005 1,125 7/1/2018
4.2.0 44,026 7/1/2018
4.2.0-beta0001 1,104 6/30/2018
4.2.0-alpha0004 1,102 7/1/2018
4.2.0-alpha0003 1,528 5/13/2018
4.2.0-alpha0002 1,159 5/13/2018
4.2.0-alpha0001 1,163 5/13/2018
4.1.2 1,416 6/30/2018
4.1.1 63,113 5/13/2018
4.1.0-beta0004 1,162 5/13/2018
4.1.0-beta0001 1,173 5/13/2018
4.1.0-alpha0016 1,495 4/14/2018
4.0.0 68,895 1/14/2018
4.0.0-beta0007 1,275 1/14/2018
4.0.0-beta0006 1,197 1/13/2018
4.0.0-beta0001 1,138 1/13/2018
3.5.0 106,858 4/14/2018
3.5.0-unstable0012 1,287 1/5/2018
3.5.0-unstable0010 1,519 8/15/2017
3.5.0-unstable0004 1,066 8/1/2017
3.5.0-unstable0003 1,078 7/25/2017
3.5.0-unstable0002 1,115 6/21/2017
3.5.0-unstable0001 1,171 6/15/2017
3.5.0-beta0001 1,336 4/14/2018
3.4.0 127,496 5/5/2017
3.4.0-unstable0009 1,119 4/5/2017
3.4.0-unstable0008 1,086 4/5/2017
3.4.0-unstable0007 1,112 4/5/2017
3.4.0-unstable0006 1,062 4/5/2017
3.4.0-unstable0004 1,195 2/15/2017
3.4.0-unstable0001 1,184 12/4/2016
3.4.0-ci0000 1,067 4/5/2017
3.3.0 75,124 11/1/2016
3.3.0-unstable0001 1,192 11/1/2016
3.3.0-unstable0000 1,084 10/10/2016
3.2.0 8,447 10/10/2016
3.2.0-beta0001 1,081 10/10/2016
3.1.0 57,241 8/25/2016
3.1.0-unstable0022 1,080 10/9/2016
3.1.0-unstable0021 1,113 10/9/2016
3.0.0-unstable0020 1,201 7/17/2016
3.0.0-unstable0017 1,162 8/24/2016
3.0.0-unstable0013 1,130 7/17/2016
3.0.0-unstable0012 1,139 7/17/2016
3.0.0-unstable0011 1,129 7/17/2016
3.0.0-beta-1 1,209 7/4/2016
3.0.0-alpha0014 1,086 7/20/2016
2.2.0-unstable0012 1,178 7/19/2016
2.1.1 19,332 7/16/2016
2.1.0 38,673 4/8/2016
2.0.0.1 1,769 4/6/2016
1.7.0 43,551 10/29/2015
1.6.0 3,398 10/25/2015
1.5.1 20,045 7/14/2015
1.5.0 1,486 7/14/2015
1.4.0 5,064 6/12/2015
1.3.0 16,997 2/1/2015
1.2.0 3,749 1/26/2015
1.1.1 6,523 11/15/2014
1.1.0 10,313 7/13/2014
1.0.0 2,898 7/2/2014
0.11.0 2,044 5/18/2014
0.10.0 1,935 4/9/2014
0.9.0 5,830 4/7/2014