开发者

How do I start and stop quartz schedular from my class method? Scheduling in spring

开发者 https://www.devze.com 2023-02-02 02:28 出处:网络
I am new to spring. I implemented schedular which invokes a method after every 10 sec. which looks like,

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.MethodInvokingJobDetailFacto开发者_如何学PythonryBean">
      <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.


Scheduler, created by SchedulerFactoryBean, has standby() and start() methods, which you can use to control firing of trigger.

0

精彩评论

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