开发者

Is there something that starts a cron in java?

开发者 https://www.devze.com 2023-04-08 10:22 出处:网络
I have some java written to do a very very simple operation. It needs to happen once every three hours an开发者_如何学编程d is not connected to any user action, it\'s just something that revolves ever

I have some java written to do a very very simple operation. It needs to happen once every three hours an开发者_如何学编程d is not connected to any user action, it's just something that revolves every three hours.

For this reason, I'm having trouble troubleshooting. The operation isn't happening. Assuming the java is intact, is there something that is supposed to "start" the cron? Or should I expect it to just be going once the server is restarted?

    <bean id="queueJob" class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.campbiche.pb.service.scheduler.BaseQuartzScheduler" />
    <property name="jobDataAsMap">
        <map>
            <entry key="processorName" value="scheduleListingActions" />
            <entry key="methodName" value="revolveQueue" />
        </map>
    </property> 
</bean>

<bean id="queueCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="queueJob" />
    <!-- run every 1 miunute -->
    <property name="cronExpression" value="*/1 * * * * ?" />
</bean>

Working in SpringSource. The Cron is set to one minute for testing. "" has already been added to a schedulerfactorybean bean as well but I did not include the code here for brevity.


It will be triggered when CronTriggerBean is instantiated.

One more thing I recall, and confirmed after looking in the docs(3.x), that you need to add your queueCronTrigger to SchedulerFactoryBean.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号