如何从我的类方法中启动和停止quartz调度?春季安排
我是春天的新手。我实现了每 10 秒后调用一个方法的调度程序。 看起来像,
<bean id="bidApprovalJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="bidApprovalOperations" />
<property name="targetMethod" value="checkExpiredAuctions" />
</bean>
<!-- Simple Trigger -->
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="bidApprovalJob" />
<property name="repeatInterval" value="10000" />
<!-- 5second delay mentioned in milliseconds -->
<property name="startDelay" value="5000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="bidApprovalJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
但是,这个计划一直在运行。我想在用户单击按钮时在运行时启动计划并在一定时间后停止它。
我可以从我的类方法启动计划吗?我可以在类中创建计划实例然后启动和停止它吗?
先感谢您。
I am new to spring. I implemented schedular which invokes a method after every 10 sec.
which looks like,
<bean id="bidApprovalJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="bidApprovalOperations" />
<property name="targetMethod" value="checkExpiredAuctions" />
</bean>
<!-- Simple Trigger -->
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="bidApprovalJob" />
<property name="repeatInterval" value="10000" />
<!-- 5second delay mentioned in milliseconds -->
<property name="startDelay" value="5000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="bidApprovalJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
But, this schedular runs all the time. I want to start the schedular at run time when user click the button and stop it after certain time.
Can I start the schedular from my class method? Can I create instance of schedular in a class and then start and stop that?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Scheduler由SchedulerFactoryBean创建,具有standby()和start()方法,您可以使用它们来控制触发器的触发。
Scheduler, created by SchedulerFactoryBean, has standby() and start() methods, which you can use to control firing of trigger.