0

We have 3 quartz.net (version 2.3.3) job configured via xml file

IInterruptableJob Job1Class is marked with DisallowConcurrentExecution and being used by both Job1 & Job2 (of course with different job data) in xml file.

IInterruptableJob Job3Class is used by Job3 in xml file.

quartz.threadPool.threadCount is set to 6 via config file.

Out of 3 job, 2 job is long running and we require that all 3 job should execute in parallel but many time we observed that it do not execute parallel. So why it is not executing in parallel.

Below is the sample xml file.

<?xml version="1.0" encoding="utf-8" ?>
<job-scheduling-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://quartznet.sourceforge.net/JobSchedulingData" version="2.0">
  <schedule>
    <job>
      <name>Job1</name>
      <group>JobGroup</group>
      <job-type>Some.Job1.Class, Some.Job1.Class.Assembly</job-type>
      <durable>false</durable>
      <recover>false</recover>
      <job-data-map>
        <entry><key>keys</key><value>values</value></entry>
      </job-data-map>
    </job>
    <trigger>
      <simple>
        <name>Job1Trigger1</name>
        <group>Triggers</group>
        <job-name>Job1</job-name>
        <job-group>JobGroup</job-group>
        <start-time-seconds-in-future>1</start-time-seconds-in-future>
        <repeat-count>0</repeat-count>
        <repeat-interval>1</repeat-interval>
      </simple>
    </trigger>
    <trigger>
      <cron>
        <name>Job1Trigger2</name>
        <group>Triggers</group>
        <job-name>Job1</job-name>
        <job-group>JobGroup</job-group>
        <cron-expression>0 0/1 * * * ?</cron-expression>
      </cron>
    </trigger>
    <job>
      <name>Job2</name>
      <group>JobGroup</group>
      <job-type>Some.Job1.Class, Some.Job1.Class.Assembly</job-type>
      <durable>false</durable>
      <recover>false</recover>
      <job-data-map>
        <entry><key>keys</key><value>values</value></entry>
      </job-data-map>
    </job>
    <trigger>
      <simple>
        <name>Job2Trigger1</name>
        <group>Triggers</group>
        <job-name>Job2</job-name>
        <job-group>JobGroup</job-group>
        <start-time-seconds-in-future>1</start-time-seconds-in-future>
        <repeat-count>1</repeat-count>
        <repeat-interval>1</repeat-interval>
      </simple>
    </trigger>
    <trigger>
      <cron>
        <name>Job2Trigger2</name>
        <group>Triggers</group>
        <job-name>Job2</job-name>
        <job-group>JobGroup</job-group>
        <cron-expression>0 0 2 1/1 * ? *</cron-expression>
      </cron>
    </trigger>
    <job>
      <name>Job3</name>
      <group>JobGroup</group>
      <job-type>Some.Job3.Class, Some.Job3.Class.Assembly</job-type>
      <durable>false</durable>
      <recover>false</recover>
      <job-data-map>
        <entry><key>keys</key><value>values</value></entry>
      </job-data-map>
    </job>
    <trigger>
      <simple>
        <name>Job3Trigger1</name>
        <group>Triggers</group>
        <job-name>Job3</job-name>
        <job-group>JobGroup</job-group>
        <start-time-seconds-in-future>1</start-time-seconds-in-future>
        <repeat-count>1</repeat-count>
        <repeat-interval>1</repeat-interval>
      </simple>
    </trigger>
    <trigger>
      <cron>
        <name>Job3Trigger2</name>
        <group>Triggers</group>
        <job-name>Job3</job-name>
        <job-group>JobGroup</job-group>
        <cron-expression>0/30 * * * * ?</cron-expression>
      </cron>
    </trigger>
  </schedule>
</job-scheduling-data>
user6096856
  • 291
  • 3
  • 9

1 Answers1

0

Job1 and Job2 can't run parallel, because you told Quartz that Job1Class has the DisallowConcurrentExecution attribute. This attribute works on classes, not on objects. Quartz won't run more than one instance of Job1Class. To fix this behavior, remove the DisallowConcurrentExecution attribute from your Job1Class and create 2 subclasses from Job1Class. One for Job1 and one for Job2. Then give each new class the attribute and it should work like you want.

Rabban
  • 2,451
  • 1
  • 19
  • 21