We have a web application running in Tomcat using Spring Framework. We need to add some scheduled jobs for recurrent operations. We came across Quartz Scheduler for this and followed a <a href="http://dimitrisli.wordpress.com/2010/09/20/spring-quartz-maven-example/" rel="nofollow">tutorial for configuring Jobs using Quartz with Spring</a> and got the jobs scheduled and running as expected.
So we have some tasks that are scheduled when the application starts. Now we want the user to manually run the jobs and change the trigger for the jobs, but we need that these changes are persisted to database. So when the application starts, it would read the persisted tasks and if they don't exist, load the default tasks from the spring descriptor file.
For simplicity's shake, let's assume that we're using the beans.xml file from the example:
So we'd like to continue using beans-like configuration for default tasks but the option to load them from database if already scheduled.
Quartz here is not a requirement, if anyone knows a easier way to achieve it using Spring
it could be useful too.
Thanks for your time.
So we have some tasks that are scheduled when the application starts. Now we want the user to manually run the jobs and change the trigger for the jobs, but we need that these changes are persisted to database. So when the application starts, it would read the persisted tasks and if they don't exist, load the default tasks from the spring descriptor file.
For simplicity's shake, let's assume that we're using the beans.xml file from the example:
Code:
<bean id="processToExecute" class="com.mycompany.ProcessToExecute" />
<bean name="processToExecuteJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.mycompany.ProcessToExecuteJob" />
<property name="jobDataAsMap">
<map>
<entry key="processToExecute" value-ref="processToExecute" />
</map>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="processToExecuteJob" />
<property name="cronExpression" value="0/5 * * * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="processToExecuteJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
So we'd like to continue using beans-like configuration for default tasks but the option to load them from database if already scheduled.
Quartz here is not a requirement, if anyone knows a easier way to achieve it using Spring
Code:
@Scheduled
Thanks for your time.