I am trying to run a Quartz Scheduler application in clustered mode. In a non-clustered setup, I am able to read/write the database without any issue. However, in a clustered setup, I encounter errors related to datasource. I read that JobStoreTX is an indicator of Cluster setup but it seems to be causing issue. Please help!
Specification:
- Springboot Gradle
- SQL Server
- using
org.springframework.boot:spring-boot-starter-quartz
@Configuration
@EnableAutoConfiguration
public class QuartzConfiguration {
private static final Logger LOG = LogManager.getLogger(QuartzConfiguration.class);
@Primary
@Bean()
@QuartzDataSource
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource quartzDataSource() {
HikariDataSource dataSource = DataSourceBuilder.create().type(HikariDataSource.class).build();
return dataSource;
}
@PostConstruct
public void validateQuartzDataSource() {
LOG.info("Quartz DataSource bean should have been created");
}
}
Note: for both setups, "Quartz DataSource bean should have been created" is logged.
org.quartz.jobstore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
LocalDataSourceJobStore - JobStoreCMT initialized. QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED' Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. NOT STARTED.
Currently in standby mode. Number of jobs executed: 0 Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads. Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered. StdSchedulerFactory
- Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
JobStoreTX initialized. QuartzScheduler:294 - Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED' Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. NOT STARTED. Currently in standby mode. Number of jobs executed: 0 Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads. Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreTX' - which supports persistence. and is not clustered. StdSchedulerFactory - Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance. JobStoreTX - Database connection shutdown unsuccessful. java.sql.SQLException: There is no DataSource named 'quartzDataSource'
-
It's referencing an externally provided properties file, probably quartz.properties, which is likely where you put that reference to JobStoreTx. What is in that file?user2529170– user25291702025年01月23日 03:54:52 +00:00Commented Jan 23, 2025 at 3:54
1 Answer 1
Thanks for those who attempted to help, I managed to resolve the issue and is successful in starting the Quartz Application in clustered mode by removing this line and keeping the rest of the mandatory cluster related configuration as it is in the application.properties file.
org.quartz.jobstore.class = org.quartz.impl.jdbcjobstore.JobStoreTX