Re-initialize Quartz ConnectionProvider on context restart

Closes gh-35208
This commit is contained in:
Juergen Hoeller
2025-07-16 15:21:49 +02:00
parent 6f5a7eed76
commit 17382fe079
4 changed files with 73 additions and 43 deletions
@@ -391,6 +391,8 @@ class QuartzSupportTests {
try (ClassPathXmlApplicationContext ctx = context("databasePersistence.xml")) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(ctx.getBean(DataSource.class));
assertThat(jdbcTemplate.queryForList("SELECT * FROM qrtz_triggers").isEmpty()).as("No triggers were persisted").isFalse();
ctx.stop();
ctx.restart();
}
}
@@ -5,28 +5,28 @@
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers" ref="trigger" />
<property name="dataSource" ref="dataSource" />
<property name="triggers" ref="trigger"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="trigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="repeatInterval" value="1000" />
<property name="repeatCount" value="1" />
<property name="repeatInterval" value="1000"/>
<property name="repeatCount" value="1"/>
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobDataAsMap">
<map>
<entry key="param" value="10" />
<entry key="param" value="10"/>
</map>
</property>
<property name="jobClass" value="org.springframework.scheduling.quartz.QuartzSupportTests$DummyJob" />
<property name="durability" value="true" />
<property name="jobClass" value="org.springframework.scheduling.quartz.QuartzSupportTests$DummyJob"/>
<property name="durability" value="true"/>
</bean>
</property>
</bean>
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="org/springframework/scheduling/quartz/quartz-hsql.sql" />
<jdbc:script location="org/springframework/scheduling/quartz/quartz-hsql.sql"/>
</jdbc:embedded-database>
</beans>