Autofac.Extras.Quartz 10.0.0
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 | ||
NuGet | ||
CodeCov |
Usage example
Autofac configuration for Quartz includes two steps:
- Scheduler registration
- 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
- 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.
No packages depend on Autofac.Extras.Quartz.
.NET 6.0
- Autofac (>= 8.0.0 && < 9.0.0)
- Quartz (>= 3.8.1 && < 4.0.0)
- JetBrains.Annotations (>= 2023.3.0)
.NET Standard 2.1
- Quartz (>= 3.8.1 && < 4.0.0)
- JetBrains.Annotations (>= 2023.3.0)
- Autofac (>= 8.0.0 && < 9.0.0)
.NET Standard 2.0
- Quartz (>= 3.8.1 && < 4.0.0)
- Autofac (>= 8.0.0 && < 9.0.0)
- JetBrains.Annotations (>= 2023.3.0)
.NET 8.0
- Quartz (>= 3.8.1 && < 4.0.0)
- Autofac (>= 8.0.0 && < 9.0.0)
- JetBrains.Annotations (>= 2023.3.0)
.NET 7.0
- Quartz (>= 3.8.1 && < 4.0.0)
- JetBrains.Annotations (>= 2023.3.0)
- Autofac (>= 8.0.0 && < 9.0.0)
Version | Downloads | Last updated |
---|---|---|
10.0.0 | 40 | 03/08/2024 |
10.0.0-alpha0007 | 30 | 03/08/2024 |
10.0.0-alpha0006 | 25 | 03/08/2024 |
9.0.0 | 42 | 05/23/2023 |
8.2.0 | 41 | 08/08/2023 |
8.2.0-alpha0001 | 32 | 08/15/2023 |
8.1.0 | 38 | 06/02/2023 |
8.1.0-alpha0003 | 36 | 04/26/2023 |
8.1.0-alpha0002 | 50 | 08/16/2023 |
8.0.0 | 62 | 07/28/2022 |
7.4.0-alpha0007 | 35 | 08/16/2023 |
7.4.0-alpha0005 | 39 | 05/26/2023 |
7.4.0-alpha0002 | 46 | 08/05/2023 |
7.3.0 | 41 | 11/11/2022 |
7.3.0-alpha0009 | 41 | 12/02/2022 |
7.2.0 | 42 | 02/21/2023 |
7.2.0-alpha0006 | 48 | 04/12/2023 |
7.1.0 | 40 | 05/31/2023 |
7.1.0-alpha0011 | 34 | 06/08/2023 |
7.1.0-alpha0010 | 33 | 08/15/2023 |
7.1.0-alpha0009 | 42 | 08/07/2023 |
7.1.0-alpha0008 | 49 | 06/06/2023 |
7.1.0-alpha0006 | 37 | 04/12/2023 |
7.1.0-alpha0004 | 33 | 08/16/2023 |
7.1.0-alpha0003 | 29 | 08/03/2023 |
7.1.0-alpha0002 | 44 | 10/10/2022 |
7.1.0-alpha0001 | 32 | 08/11/2023 |
7.0.0 | 50 | 07/06/2023 |
7.0.0-beta0001 | 41 | 05/03/2023 |
7.0.0-alpha0024 | 36 | 08/16/2023 |
7.0.0-alpha0023 | 30 | 10/05/2022 |
6.3.0-alpha0001 | 42 | 11/11/2022 |
6.2.0 | 44 | 06/02/2023 |
6.2.0-beta0001 | 29 | 08/15/2023 |
6.2.0-alpha0008 | 33 | 08/15/2023 |
6.2.0-alpha0001 | 32 | 11/06/2022 |
6.1.0 | 54 | 05/17/2023 |
6.1.0-beta0001 | 37 | 10/19/2022 |
6.0.1 | 56 | 10/28/2022 |
6.0.1-beta0001 | 33 | 08/08/2023 |
6.0.0 | 52 | 05/13/2023 |
6.0.0-beta0001 | 31 | 05/15/2023 |
6.0.0-alpha0041 | 32 | 08/20/2023 |
6.0.0-alpha0039 | 40 | 06/01/2023 |
5.4.0 | 34 | 11/25/2022 |
5.4.0-beta0001 | 33 | 09/24/2022 |
5.4.0-alpha0007 | 33 | 08/09/2023 |
5.4.0-alpha0001 | 37 | 10/14/2023 |
5.3.0 | 33 | 08/06/2023 |
5.3.0-beta0001 | 37 | 08/11/2023 |
5.3.0-alpha0009 | 34 | 06/12/2023 |
5.3.0-alpha0008 | 49 | 05/24/2023 |
5.3.0-alpha0007 | 35 | 05/28/2023 |
5.3.0-alpha0001 | 39 | 05/19/2023 |
5.2.0 | 35 | 08/16/2023 |
5.2.0-beta0001 | 49 | 08/07/2023 |
5.2.0-alpha0023 | 36 | 08/06/2023 |
5.2.0-alpha0021 | 34 | 08/12/2023 |
5.1.0 | 63 | 09/13/2022 |
5.1.0-alpha0015 | 42 | 06/06/2023 |
5.1.0-alpha0014 | 33 | 06/05/2023 |
5.1.0-alpha0005 | 34 | 05/07/2023 |
5.0.0 | 48 | 04/26/2023 |
5.0.0-beta0001 | 38 | 08/21/2023 |
5.0.0-alpha0064 | 35 | 08/22/2023 |
4.7.0-alpha0013 | 32 | 05/29/2023 |
4.7.0-alpha0009 | 30 | 08/11/2023 |
4.7.0-alpha0007 | 35 | 08/14/2023 |
4.7.0-alpha0006 | 38 | 12/06/2022 |
4.7.0-alpha0005 | 39 | 05/04/2023 |
4.7.0-alpha0004 | 48 | 09/28/2022 |
4.6.0 | 36 | 08/25/2022 |
4.6.0-beta0001 | 50 | 08/06/2023 |
4.6.0-alpha0036 | 44 | 08/03/2023 |
4.6.0-alpha0034 | 32 | 05/04/2023 |
4.6.0-alpha0033 | 35 | 08/03/2023 |
4.6.0-alpha0028 | 37 | 09/05/2023 |
4.6.0-alpha0026 | 47 | 09/24/2023 |
4.6.0-alpha0024 | 30 | 08/02/2023 |
4.6.0-alpha0022 | 32 | 07/29/2023 |
4.6.0-alpha0018 | 35 | 08/14/2023 |
4.6.0-alpha0008 | 36 | 06/16/2023 |
4.6.0-alpha0005 | 32 | 08/09/2023 |
4.6.0-alpha0003 | 32 | 06/04/2023 |
4.6.0-alpha0001 | 34 | 07/22/2023 |
4.5.1 | 61 | 05/03/2023 |
4.5.1-beta0001 | 35 | 05/03/2023 |
4.5.0 | 57 | 08/24/2023 |
4.5.0-beta0001 | 48 | 07/29/2023 |
4.5.0-alpha0008 | 35 | 08/24/2023 |
4.5.0-alpha0007 | 33 | 08/15/2023 |
4.5.0-alpha0005 | 37 | 05/19/2023 |
4.5.0-alpha0003 | 41 | 09/10/2022 |
4.5.0-alpha0002 | 36 | 08/16/2023 |
4.5.0-alpha0001 | 49 | 11/12/2022 |
4.4.0 | 39 | 10/12/2022 |
4.4.0-beta0001 | 38 | 09/25/2022 |
4.4.0-alpha0014 | 35 | 08/19/2023 |
4.4.0-alpha0013 | 34 | 11/26/2022 |
4.4.0-alpha0012 | 29 | 08/14/2023 |
4.4.0-alpha0002 | 52 | 07/14/2023 |
4.4.0-alpha0001 | 32 | 08/17/2023 |
4.3.0 | 56 | 10/23/2022 |
4.3.0-beta0001 | 33 | 10/20/2023 |
4.3.0-alpha0008 | 39 | 08/04/2023 |
4.3.0-alpha0007 | 31 | 08/10/2023 |
4.3.0-alpha0006 | 46 | 05/15/2023 |
4.3.0-alpha0005 | 33 | 05/30/2023 |
4.2.0 | 37 | 05/16/2023 |
4.2.0-beta0001 | 50 | 07/09/2023 |
4.2.0-alpha0004 | 34 | 11/10/2022 |
4.2.0-alpha0003 | 29 | 08/10/2023 |
4.2.0-alpha0002 | 34 | 08/18/2023 |
4.2.0-alpha0001 | 35 | 08/17/2023 |
4.1.2 | 38 | 08/21/2023 |
4.1.1 | 43 | 05/21/2023 |
4.1.0-beta0004 | 35 | 07/30/2023 |
4.1.0-beta0001 | 40 | 04/01/2023 |
4.1.0-alpha0016 | 33 | 08/17/2023 |
4.0.0 | 38 | 10/26/2022 |
4.0.0-beta0007 | 41 | 10/27/2022 |
4.0.0-beta0006 | 38 | 05/19/2023 |
4.0.0-beta0001 | 47 | 08/24/2023 |
3.5.0 | 58 | 05/08/2023 |
3.5.0-unstable0012 | 32 | 10/17/2022 |
3.5.0-unstable0010 | 43 | 08/15/2023 |
3.5.0-unstable0004 | 40 | 10/22/2022 |
3.5.0-unstable0003 | 53 | 04/28/2023 |
3.5.0-unstable0002 | 48 | 07/31/2023 |
3.5.0-unstable0001 | 46 | 06/21/2023 |
3.5.0-beta0001 | 41 | 08/21/2023 |
3.4.0 | 55 | 04/15/2023 |
3.4.0-unstable0009 | 47 | 05/25/2023 |
3.4.0-unstable0008 | 44 | 09/23/2023 |
3.4.0-unstable0007 | 35 | 08/06/2023 |
3.4.0-unstable0006 | 35 | 08/16/2023 |
3.4.0-unstable0004 | 45 | 08/08/2023 |
3.4.0-unstable0001 | 50 | 05/02/2023 |
3.4.0-ci0000 | 37 | 05/08/2023 |
3.3.0 | 39 | 08/05/2023 |
3.3.0-unstable0001 | 44 | 05/14/2023 |
3.3.0-unstable0000 | 33 | 08/11/2023 |
3.2.0 | 32 | 08/30/2022 |
3.2.0-beta0001 | 35 | 10/26/2022 |
3.1.0 | 41 | 08/29/2022 |
3.1.0-unstable0022 | 33 | 08/17/2023 |
3.1.0-unstable0021 | 35 | 08/18/2023 |
3.0.0-unstable0020 | 52 | 06/16/2023 |
3.0.0-unstable0017 | 43 | 08/25/2023 |
3.0.0-unstable0013 | 35 | 06/13/2023 |
3.0.0-unstable0012 | 35 | 04/27/2023 |
3.0.0-unstable0011 | 35 | 08/21/2023 |
3.0.0-beta-1 | 36 | 10/23/2022 |
3.0.0-alpha0014 | 47 | 08/22/2023 |
2.2.0-unstable0012 | 35 | 03/03/2023 |
2.1.1 | 31 | 08/12/2023 |
2.1.0 | 63 | 10/16/2022 |
2.0.0.1 | 51 | 11/12/2022 |
1.7.0 | 55 | 06/01/2023 |
1.6.0 | 36 | 08/11/2023 |
1.5.1 | 46 | 05/10/2023 |
1.5.0 | 59 | 08/15/2023 |
1.4.0 | 66 | 10/24/2022 |
1.3.0 | 42 | 08/11/2023 |
1.2.0 | 39 | 08/08/2023 |
1.1.1 | 39 | 08/11/2023 |
1.1.0 | 38 | 08/12/2023 |
1.0.0 | 33 | 05/09/2023 |
0.11.0 | 57 | 06/04/2023 |
0.10.0 | 33 | 06/07/2023 |
0.9.0 | 63 | 07/02/2023 |