问题
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.?
回答1:
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.
来源:https://stackoverflow.com/questions/23390698/what-is-exactly-mean-by-disallowconcurrentexecution-in-quartz-net