Java scheduler

What is the best way to start a process in a scheduler. I can either do it crontab or Spring -Batch. Any other better option?

+3
source share
5 answers

Quartz

Quartz is a full-featured, open-source job scheduling system that can be integrated or used along the side of virtually any J2EE or J2SE application - from the smallest standalone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for performing tens, hundreds or even tens of thousands of jobs; Jobs jobs are defined as standard Java components or EJBs. Quartz Scheduler includes many enterprise-class features such as JTA transaction and clustering.

+6
source

You can also see Quartz if you want to schedule tasks in one virtual machine.

- , crontab.

+1

, . .

GUI- - MAESTRO. .

0

Spring + , Spring . .

http://static.springsource.org/spring/docs/2.5.x/reference/scheduling.html

Spring + Quartz MethodInvokingJobDetailFactoryBean, bean ( ).

orderService.cancelNotPaidOrders() 30 :

<bean id="cancelExpiredOrders" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetBeanName" value="orderService"/>
        <property name="targetMethod" value="cancelNotPaidOrders"/>
        <property name="concurrent" value="false" />
</bean>

<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="cancelExpiredOrders" />
        <property name="startDelay" value="10000" />
        <property name="repeatInterval" value="1800000" />
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="simpleTrigger" />
            </list>
        </property>
</bean>
0

Source: https://habr.com/ru/post/1718367/


All Articles