Spring Quartz scheduler
Spring is bundled with a scheduler that you can configure to be used in your application. This is typically useful for daemon processes which are supposed to kick off at a certain defined interval.
This can be very simply achieved using the SimpleTriggerFactoryBean.
To create this , you would need to have the following information handy:
1. targetObject - The name of the bean referred from Spring whose method is to be invoked.
2. targetMethod - Name of the method that is to be invoked.
3. Concurrent - True or false
4. Start delay - The initial delay after daemon service start up in milliseconds.
5. Repeat interval - Time interval after which the method should be invoked repeatedly.
Here is a sample code you can use to create such a daemon service .
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<bean class="java.util.ArrayList">
<constructor-arg>
<list>
<bean class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" value="<name of class bean>">
<property name="targetMethod" value="<method to be invoked>">
<property name="concurrent" value="false">
</bean>
</property>
<property name="startDelay" value="<your value>" />
<property name="repeatInterval" value="<your value>" />
</bean>
</list>
</constructor-arg>
</bean>
</property>
<property name="autoStartup" value="true" />
</bean>
Comments
Post a Comment