Search code examples
javaspringquartz-schedulerschedulercrontrigger

Is there something that starts a cron in java?


I have some java written to do a very very simple operation. It needs to happen once every three hours and 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.


Solution

  • 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.