service - Autofac.Extras.Quartz with ConcurrentExecutionDisallowed not working -


in windows service using quartz.net autofac. assist me here using nuget autofac.extras.quartz. far good, when try apply disallowconcurrencyexecution attribute ignored , multiple jobs spawned.

i using follows:

registration

builder.registermodule(new quartzautofacfactorymodule()); builder.registertype<companydatabaseprocessor>().as<ijob>().instanceperlifetimescope(); 

setup

var fact = container.resolve<ijobfactory>();  _scheduler = stdschedulerfactory.getdefaultscheduler(); _scheduler.jobfactory = fact; _scheduler.start();  var job = jobbuilder.create<ijob>()     .withidentity("qprocjob", "a3group")     .build();  var trigger = triggerbuilder.create()     .withidentity("qproctrigger", "a3group")     .startnow()     .withsimpleschedule(x => x         .withintervalinseconds(executeevery)         .repeatforever())     .build();  _scheduler.schedulejob(job, trigger); 

and when in ijob, check context.jobdetail.concurrentexecutiondisallowed set false.

i see question old, encountered same problem , going post solution, useful someone. problem when use jobfactory, type of job unknown quartz, assigns internal type (noopjob) not decorated disallowconcurrentexecution attribute, causing jobdetailimpl(the class used quartz.net ijobdetail) return false in concurrentexecutiondisallowed property. did simple class inherits jobdetailimpl , add extensions method build jobbuilder class maintain same fluent code in job creation. here code:

public class singlejobdetail : jobdetailimpl {     public singlejobdetail() : base()     {     }      public override bool concurrentexecutiondisallowed => true; }  public static class jobhelper {     public static ijobdetail build(this jobbuilder builder, bool disallowconcurrent)     {         var job = builder.build();         if (!disallowconcurrent)             return job;          var singlejob = new singlejobdetail();         singlejob.jobtype = job.jobtype;         singlejob.description = job.description;         singlejob.key = job.key;         singlejob.durable = job.durable;         singlejob.requestsrecovery = job.requestsrecovery;          if (!singlejob.jobdatamap.isempty)             singlejob.jobdatamap = job.jobdatamap;          return singlejob;     } } 

and in job creation:

var job = jobbuilder.create().withidentity(id).build(true); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -