在Quartz中使用批处理模式

时间:2017-02-01 07:56:26

标签: java spring quartz-scheduler

为了提高石英的性能,我打算按照Performance Tuning on Quartz Scheduler

的建议在石英中使用批处理

我们创建了与spring集成的石英调度程序,如下所示。

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <!-- Quartz requires a separate 'quartz.properties' file -->
        <property name="configLocation" value="classpath:/quartz.properties"/>

        <!-- Naturally, Quartz with the DB requires references
              to the data source and transaction manager beans -->
        <property name="dataSource" ref="quartzDataSource"/>
        <!--<property name="transactionManager" ref="transactionManager"/>-->

        <!-- reference to our 'autowiring job factory bean', defined above: -->
        <property name="jobFactory" ref="quartzJobFactory"/>

        <!-- Boolean controlling whether you want to override
              the job definitions in the DB on the app start up.
              We'll talk about it more in the next section. -->
        <property name="overwriteExistingJobs" value="true"/>

        <!-- I will not explain the next three properties, just use it as shown: -->
        <property name="autoStartup" value="${isQuartzEnabled}" />
        <property name="schedulerName" value="quartzScheduler"/>
        <property name="applicationContextSchedulerContextKey" value="applicationContext"/>

        <!-- Controls whether to wait for jobs completion on app shutdown, we use 'true' -->
        <property name="waitForJobsToCompleteOnShutdown"
                  value="true"/>

        <!-- Tell the Quartz scheduler about the triggers.
              We have implemented the 'quartzTriggers' bean in the 'Jobs and triggers' section.
              No need to pass job definitions, since triggers created via Spring know their jobs.
              Later we'll see a case when we'll have to disable this and pass the jobs explicitly.-->
        <property name="triggers" ref="quartzTriggers"/>

    </bean>

如何指定 maxBatchSize &amp; DirectSchedulerFactory中createScheduler batchTimeWindow

2 个答案:

答案 0 :(得分:4)

我发现我们可以通过在quartz.properties文件中配置以下属性来实现

org.quartz.scheduler.batchTriggerAcquisitionMaxCount

参考:Configure Main Scheduler Settings

答案 1 :(得分:0)

  • time concentration 10:29:19 1814.04 10:29:20 1815.80 10:29:21 1816.09 10:29:22 1817.52 10:29:23 1819.10 10:29:24 1818.25 10:29:25 1818.35 10:29:26 1819.10 10:29:27 1820.31 10:29:28 1819.63 10:29:29 1818.94 10:29:30 1818.91 10:29:31 1819.58 10:29:32 1818.73 10:29:33 1820.21 10:29:34 1821.64 10:29:35 1819.39 10:29:36 1818.52 10:29:37 1819.58 10:29:38 1820.27 10:29:39 1818.99 10:29:40 1819.77 10:29:41 1820.08 10:29:42 1820.13 10:29:43 1819.26 10:29:44 1820.50 10:29:45 1820.12 10:29:46 1818.45 10:29:47 1819.54 Here is the break in time. It jumps from 10:29:47 to 10:31:00 10:31:00 1129.30 10:31:01 2673.05 10:31:02 2492.65 10:31:03 2232.31 10:31:04 2190.14 将设置 org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow
  • batchTimeWindow 将设置 org.quartz.scheduler.batchTriggerAcquisitionMaxCount 属性。

来源:https://github.com/quartz-scheduler/quartz/blob/master/quartz-core/src/main/java/org/quartz/impl/StdSchedulerFactory.java