GithubHelp home page GithubHelp logo

twkun / autofac.extras.quartz Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alphacloud/autofac.extras.quartz

0.0 1.0 0.0 815 KB

Autofac integration for Quartz.Net

License: MIT License

C# 100.00%

autofac.extras.quartz's Introduction

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

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.

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>();
scheduler.Start();

Sample project

See src/Samples/SampleService for windows service implementation based on TopShelf.

autofac.extras.quartz's People

Contributors

shatl avatar kjellski avatar chriseldredge avatar jafin avatar

Watchers

twkun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.