首页 > 代码库 > spring boot + quartz 集群
spring boot + quartz 集群
spring boot bean配置:
@Configuration
public class QuartzConfig {
@Value("${quartz.scheduler.instanceName}")
private String quartzInstanceName;
@Value("${org.quartz.dataSource.myDS.driver}")
private String myDSDriver;
@Value("${org.quartz.dataSource.myDS.URL}")
private String myDSURL;
@Value("${org.quartz.dataSource.myDS.user}")
private String myDSUser;
@Value("${org.quartz.dataSource.myDS.password}")
private String myDSPassword;
@Value("${org.quartz.dataSource.myDS.maxConnections}")
private String myDSMaxConnections;
/**
* 设置属性
* @return
* @throws IOException
*/
private Properties quartzProperties() throws IOException {
Properties prop = new Properties();
prop.put("quartz.scheduler.instanceName", quartzInstanceName);
prop.put("org.quartz.scheduler.instanceId", "AUTO");
prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
prop.put("org.quartz.scheduler.jmx.export", "true");
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
prop.put("org.quartz.jobStore.dataSource", "quartzDataSource");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
prop.put("org.quartz.jobStore.isClustered", "true");
prop.put("org.quartz.jobStore.clusterCheckinInterval", "20000");
prop.put("org.quartz.jobStore.dataSource", "myDS");
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop.put("org.quartz.jobStore.misfireThreshold", "120000");
prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE");
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount",