java-在Quartz中使用批处理模式
作者:互联网
为了提高石英的性能,我打算按照Performance Tuning on Quartz Scheduler中的建议在石英中使用批处理
我们创建与弹簧集成的石英调度器,如下所示.
<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& DirectSchedulerFactory中的createScheduler batchTimeWindow?
解决方法:
我发现我们可以通过在quartz.properties文件中配置以下属性来实现
org.quartz.scheduler.batchTriggerAcquisitionMaxCount
参考:Configure Main Scheduler Settings
标签:quartz-scheduler,spring,java 来源: https://codeday.me/bug/20191026/1935351.html