Autofac integration for Quartz.Net
Clone or download
Latest commit f28f37c Oct 3, 2018
Failed to load latest commit information.
.github Update lock.yml Oct 2, 2018
src Release 4.3.0 Sep 29, 2018
.editorconfig Release 4.3.0 Sep 29, 2018
.gitattributes Initial revision Apr 7, 2014
.gitignore Release 4.3.0 Sep 29, 2018 Release 4.3.0 Sep 29, 2018
GitReleaseManager.yaml Release 4.3.0 Sep 29, 2018
GitVersion.yml Release 4.1.0 May 13, 2018
LICENSE Initial commit Apr 7, 2014 Release 4.1.0 May 13, 2018
appveyor.yml Release 4.3.0 Sep 29, 2018
build.cake Release 4.3.0 Sep 29, 2018
build.ps1 Release 4.3.0 Sep 29, 2018 Release 4.3.0 Sep 29, 2018
cake.config Release 4.3.0 Sep 29, 2018


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 consists of 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 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>();

Sample projects

  • See src/Samples/Console for .NetCore console application.
  • src/Samples/Shared contains source code shared between samples.

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