Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is exactly mean by 'DisallowConcurrentExecution' in Quartz.net

I have a Quartz.net Job with the following definition.

    [PersistJobDataAfterExecution]
    [DisallowConcurrentExecution]
    public class AdItemsJob : IJob, IInterruptableJob
    {

        public void Execute(IJobExecutionContext context)
        { 
         // Job execution logic,

        }
   }

As I have decorated the Job with DisallowConcurrentExecution attribute.
What I know about this attribute, we can't run multiple instances of same job at the same time. What is meant by multiple instances here.?
Does the two jobs of AddItemsJob with different key are called same instances or different instances.?
Does two jobs with different key can execute at the same time.?

like image 541
Ishtiaq Avatar asked Apr 30 '14 14:04

Ishtiaq


People also ask

What is Jobkey in Quartz?

Uniquely identifies a JobDetail . Keys are composed of both a name and group, and the name must be unique within the group. If only a group is specified then the default group name will be used. Quartz provides a builder-style API for constructing scheduling-related entities via a Domain-Specific Language (DSL).

What is JobDataMap in Quartz?

Holds state information for Job instances. JobDataMap instances are stored once when the Job is added to a scheduler. They are also re-persisted after every execution of StatefulJob instances. JobDataMap instances can also be stored with a Trigger .


1 Answers

A job instance is a job with unique key. So having a job of type AddItemsJob can have two instances with keys AddItemsJob.Admin and AddItemsJobs.Legacy. The concurrency protection comes per job key - the aforementioned two jobs could run simultaneously if they were defined with overlapping triggers. Having a single job defined behind single key would not run simultaneously even if there were multiple triggers having overlapping schedules associated with it.

like image 80
Marko Lahma Avatar answered Oct 06 '22 23:10

Marko Lahma