31 December, 2007

Spring->Qiartz->Concurrent job

Using the MethodInvokingJobDetailFactoryBean, you don't need to create one-line jobs that just invoke a method, and you only need to create the actual business object and wire up the detail object.
By default, Quartz Jobs are stateless, resulting in the possibility of jobs interfering with each other. If you specify two triggers for the same JobDetail, it might be possible that before the first job has finished, the second one will start. If JobDetail classes implement the Stateful interface, this won't happen. The second job will not start before the first one has finished. To make jobs resulting from the MethodInvokingJobDetailFactoryBean non-concurrent, set the concurrent flag to false.



<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

<property name="targetObject" ref="exampleBusinessObject">

<property name="targetMethod" value="doIt">

<property name="concurrent" value="false">

</bean>


оч хороший пример : http://firstpartners.net/kb/index.php/Cron_Timer_functionality_using_Spring_and_Quartz

No comments: