Reputation: 2305
I have problem integrating my spring with quartz. I have class UserService which has methods delegated to another class, which changes data in database. I have added maven dependency for quartz and others needed, in my mvc-context I have declared bean
<bean id="quartzjob" class="example.UserService"/>
Then the factory bean
<bean id="runJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="quartzjob" />
<property name="targetMethod" value="testQuartz" />
And finally trigger
<bean id="Trigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="runJob" />
<property name="startDelay" value="1000"/>
<property name="repeatInterval" value="5000"/>
What my test method does, it delegates method to another class in which one record from database should be updated (This method works fine, because I'm using it already) however after that 5 seconds record is not updated, seems that something is wrong with quartz because methods were tested. Any ideas?
Upvotes: 1
Views: 971
Reputation: 1781
You also need to wire in your trigger to the quartz scheduler. Add this to your spring config.
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="Trigger" />
</list>
</property>
</bean>
Upvotes: 2