Autofac.Extras.Quartz 10.0.0-alpha0006

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.

No packages depend on Autofac.Extras.Quartz.

.NET 6.0

.NET 7.0

.NET 8.0

.NET Standard 2.0

.NET Standard 2.1

Version Downloads Last updated
11.1.0-alpha0002 31 03/06/2026
11.0.0 25 03/06/2026
10.1.0-alpha0007 27 02/10/2026
10.0.0 27 12/13/2025
10.0.0-alpha0007 36 12/11/2025
10.0.0-alpha0006 26 12/20/2025
9.0.0 20 12/12/2025
8.2.0 25 12/13/2025
8.2.0-alpha0001 23 12/14/2025
8.1.0 22 12/16/2025
8.1.0-alpha0003 24 12/14/2025
8.1.0-alpha0002 25 12/20/2025
8.0.0 25 12/13/2025
7.4.0-alpha0007 23 12/14/2025
7.4.0-alpha0005 26 12/20/2025
7.4.0-alpha0002 29 12/14/2025
7.3.0 28 12/14/2025
7.3.0-alpha0009 32 12/15/2025
7.2.0 25 12/14/2025
7.2.0-alpha0006 26 12/20/2025
7.1.0 24 01/09/2026
7.1.0-alpha0011 27 12/15/2025
7.1.0-alpha0010 33 12/10/2025
7.1.0-alpha0009 24 12/15/2025
7.1.0-alpha0008 26 12/20/2025
7.1.0-alpha0006 21 12/12/2025
7.1.0-alpha0004 29 12/17/2025
7.1.0-alpha0003 27 12/20/2025
7.1.0-alpha0002 25 12/12/2025
7.1.0-alpha0001 24 12/19/2025
7.0.0 22 12/13/2025
7.0.0-beta0001 25 12/15/2025
7.0.0-alpha0024 29 12/13/2025
7.0.0-alpha0023 27 12/14/2025
6.3.0-alpha0001 27 12/14/2025
6.2.0 23 12/12/2025
6.2.0-beta0001 29 12/09/2025
6.2.0-alpha0008 24 12/16/2025
6.2.0-alpha0001 25 12/17/2025
6.1.0 24 12/14/2025
6.1.0-beta0001 27 12/10/2025
6.0.1 24 12/13/2025
6.0.1-beta0001 22 12/10/2025
6.0.0 25 12/15/2025
6.0.0-beta0001 23 12/10/2025
6.0.0-alpha0041 26 12/12/2025
6.0.0-alpha0039 23 12/20/2025
5.4.0 24 12/22/2025
5.4.0-beta0001 28 12/15/2025
5.4.0-alpha0007 23 12/13/2025
5.4.0-alpha0001 23 12/14/2025
5.3.0 25 12/12/2025
5.3.0-beta0001 28 12/13/2025
5.3.0-alpha0009 25 12/20/2025
5.3.0-alpha0008 23 12/20/2025
5.3.0-alpha0007 28 12/11/2025
5.3.0-alpha0001 23 12/15/2025
5.2.0 24 12/13/2025
5.2.0-beta0001 27 12/13/2025
5.2.0-alpha0023 22 12/20/2025
5.2.0-alpha0021 25 12/17/2025
5.1.0 22 12/14/2025
5.1.0-alpha0015 28 12/14/2025
5.1.0-alpha0014 26 12/15/2025
5.1.0-alpha0005 26 12/20/2025
5.0.0 24 12/12/2025
5.0.0-beta0001 31 12/15/2025
5.0.0-alpha0064 29 12/11/2025
4.7.0-alpha0013 31 12/11/2025
4.7.0-alpha0009 23 12/12/2025
4.7.0-alpha0007 26 12/14/2025
4.7.0-alpha0006 25 12/20/2025
4.7.0-alpha0005 27 12/11/2025
4.7.0-alpha0004 23 12/20/2025
4.6.0 27 12/15/2025
4.6.0-beta0001 26 12/11/2025
4.6.0-alpha0036 26 12/15/2025
4.6.0-alpha0034 24 12/14/2025
4.6.0-alpha0033 30 12/14/2025
4.6.0-alpha0028 28 12/14/2025
4.6.0-alpha0026 30 12/12/2025
4.6.0-alpha0024 24 12/13/2025
4.6.0-alpha0022 29 12/14/2025
4.6.0-alpha0018 33 12/15/2025
4.6.0-alpha0008 22 12/20/2025
4.6.0-alpha0005 24 12/20/2025
4.6.0-alpha0003 22 12/20/2025
4.6.0-alpha0001 34 12/15/2025
4.5.1 26 12/13/2025
4.5.1-beta0001 25 12/15/2025
4.5.0 23 12/13/2025
4.5.0-beta0001 23 12/20/2025
4.5.0-alpha0008 23 12/20/2025
4.5.0-alpha0007 21 12/12/2025
4.5.0-alpha0005 22 12/15/2025
4.5.0-alpha0003 28 12/10/2025
4.5.0-alpha0002 22 12/14/2025
4.5.0-alpha0001 23 12/15/2025
4.4.0 22 12/20/2025
4.4.0-beta0001 30 12/15/2025
4.4.0-alpha0014 24 12/20/2025
4.4.0-alpha0013 17 12/14/2025
4.4.0-alpha0012 23 12/20/2025
4.4.0-alpha0002 21 12/20/2025
4.4.0-alpha0001 33 12/15/2025
4.3.0 24 12/23/2025
4.3.0-beta0001 27 12/15/2025
4.3.0-alpha0008 29 12/15/2025
4.3.0-alpha0007 27 12/15/2025
4.3.0-alpha0006 27 12/12/2025
4.3.0-alpha0005 29 12/13/2025
4.2.0 27 12/22/2025
4.2.0-beta0001 19 12/13/2025
4.2.0-alpha0004 21 12/13/2025
4.2.0-alpha0003 24 12/14/2025
4.2.0-alpha0002 23 12/15/2025
4.2.0-alpha0001 27 12/15/2025
4.1.2 25 12/13/2025
4.1.1 24 12/12/2025
4.1.0-beta0004 32 12/15/2025
4.1.0-beta0001 27 12/13/2025
4.1.0-alpha0016 28 12/10/2025
4.0.0 27 12/10/2025
4.0.0-beta0007 27 12/13/2025
4.0.0-beta0006 22 12/11/2025
4.0.0-beta0001 18 12/15/2025
3.5.0 24 12/13/2025
3.5.0-unstable0012 24 12/15/2025
3.5.0-unstable0010 27 12/15/2025
3.5.0-unstable0004 24 12/20/2025
3.5.0-unstable0003 21 12/20/2025
3.5.0-unstable0002 23 12/20/2025
3.5.0-unstable0001 28 12/14/2025
3.5.0-beta0001 25 12/15/2025
3.4.0 22 12/24/2025
3.4.0-unstable0009 28 12/15/2025
3.4.0-unstable0008 21 12/15/2025
3.4.0-unstable0007 23 12/15/2025
3.4.0-unstable0006 27 12/20/2025
3.4.0-unstable0004 29 12/18/2025
3.4.0-unstable0001 24 12/14/2025
3.4.0-ci0000 24 12/20/2025
3.3.0 22 12/12/2025
3.3.0-unstable0001 20 12/20/2025
3.3.0-unstable0000 24 12/15/2025
3.2.0 23 12/13/2025
3.2.0-beta0001 24 12/15/2025
3.1.0 23 12/14/2025
3.1.0-unstable0022 28 12/15/2025
3.1.0-unstable0021 27 12/20/2025
3.0.0-unstable0020 26 12/15/2025
3.0.0-unstable0017 26 12/20/2025
3.0.0-unstable0013 27 12/20/2025
3.0.0-unstable0012 23 12/13/2025
3.0.0-unstable0011 30 12/09/2025
3.0.0-beta-1 19 12/20/2025
3.0.0-alpha0014 33 12/20/2025
2.2.0-unstable0012 20 12/20/2025
2.1.1 26 12/20/2025
2.1.0 25 12/10/2025
2.0.0.1 24 12/15/2025
1.7.0 26 12/11/2025
1.6.0 25 12/11/2025
1.5.1 24 12/10/2025
1.5.0 31 12/11/2025
1.4.0 28 12/13/2025
1.3.0 27 12/11/2025
1.2.0 25 12/11/2025
1.1.1 22 12/12/2025
1.1.0 26 12/11/2025
1.0.0 30 12/12/2025
0.11.0 21 12/12/2025
0.10.0 27 12/11/2025
0.9.0 26 12/12/2025