Ich Start/Stop die Stelle (n) mit diesen Methoden:Wie kann ich die Planung von Jobs dynamisch mit Spring/Quartz ändern?
ClassPathXmlApplicationContext scheduleContext;
public void startJobs() {
scheduleContext = new ClassPathXmlApplicationContext("applicationContext.xml");
}
public void stopJobs() {
scheduleContext.close();
}
applicationContext.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd">
<bean name="quartzJob"
class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="mypackage.TestSpringJob" />
<property name="durability" value="true" />
</bean>
<bean id="simpleTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="quartzJob" />
<property name="repeatInterval" value="2000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="quartzJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
</beans>
Ist es möglich, zum Beispiel der repeatInterval
Eigenschaft eines Auftrags zu ändern oder hinzufügen neue Jobs in den Scheduler dynamisch?
Wenn ja, wie kann ich das erreichen?
Ich habe in StackOverflow gesucht, aber keine Antwort auf Ihre Frage gefunden. Es gibt andere Fragen im Zusammenhang mit Quarz ändern, aber sie scheinen nicht zu Ihrem Problem passen. Vielleicht hilft das https://darthanthony.wordpress.com/2009/07/07/dynamic-scheduling-with-avaspring/ – RubioRic