How to start and stop a quartz chart from a class method? Spring planning

I am new to spring. I have implemented a schedule that calls a method every 10 seconds. 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 schedule works all the time. I want to start a schedule at runtime when the user clicks a button and stops it after a certain time.

Can I run a schedule from my class method? Can I instantiate a schedule in a class and then start and stop this?

Thanks in advance.

+3
source share
1 answer

The scheduler created by SchedulerFactoryBean has standby () and start () methods, which you can use to control the trigger's launch.

+3
source

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


All Articles