quartz 延時啟動、併發性設定
阿新 • • 發佈:2019-02-12
1、設定延時:在schedule中設定startupDelay的值
<beans>
<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="dataSource" ref="dataSource" />
<property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
<property name="configLocation" value="classpath:quartz.properties" />
<!-- 延時啟動,這個很重要,必須要有足夠長的時間讓你的應用先啟動完成後再讓 Scheduler啟動,
這裡設定60秒,如果你的應用啟動時間較長,要相應增加startupDelay的時間-->
<property name="startupDelay" value="60"/>
<property name="overwriteExistingJobs" value="true" />
</bean>
</beans>
2、併發性設定:在jobDetail中設定concurrent的值
<bean id="resultJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 呼叫的類 -->
<property name="targetObject" ref="resultJob"></property>
<!-- 呼叫類中的方法 -->
<property name="targetMethod" value="createDemEmps"></property>
<property name="concurrent" value="false" />
</bean>