在 Quartz 中使用批处理模式

Vin*_*ran 4 java spring 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>
Run Code Online (Sandbox Code Playgroud)

如何指定maxBatchSizebatchTimeWindowcreateScheduler在DirectSchedulerFactory?

Vin*_*ran 5

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

org.quartz.scheduler.batchTriggerAcquisitionMaxCount

参考:配置主调度程序设置