本文整理匯總了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean.setSchedulerName方法的典型用法代碼示例。如果您正苦於以下問題:Java SchedulerFactoryBean.setSchedulerName方法的具體用法?Java SchedulerFactoryBean.setSchedulerName怎麽用?Java SchedulerFactoryBean.setSchedulerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.scheduling.quartz.SchedulerFactoryBean
的用法示例。
在下文中一共展示了SchedulerFactoryBean.setSchedulerName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
//quartz參數
Properties prop = new Properties();
prop.put("org.quartz.scheduler.instanceName", "RenrenScheduler");
prop.put("org.quartz.scheduler.instanceId", "AUTO");
//線程池配置
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount", "20");
prop.put("org.quartz.threadPool.threadPriority", "5");
//JobStore配置
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
//集群配置
// prop.put("org.quartz.jobStore.isClustered", "true");
// prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
// prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop);
factory.setSchedulerName("RenrenScheduler");
//延時啟動
factory.setStartupDelay(30);
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
//可選,QuartzScheduler 啟動時更新己存在的Job,這樣就不用每次修改targetObject後刪除qrtz_job_details表對應記錄了
factory.setOverwriteExistingJobs(true);
//設置自動啟動,默認為true
factory.setAutoStartup(true);
return factory;
}
示例2: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public SchedulerFactoryBean schedulerFactoryBean(
DataSource dataSource, PlatformTransactionManager transactionManager, JobFactory jobFactory) {
final SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setOverwriteExistingJobs(true);
factory.setTaskExecutor(commonTaskScheduler.getScheduledExecutor());
factory.setDataSource(dataSource);
factory.setTransactionManager(transactionManager);
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties);
factory.setSchedulerName(SCHEDULER_NAME);
factory.setAutoStartup(true);
factory.setWaitForJobsToCompleteOnShutdown(true);
// Delay added to avoid errors caused by updating registered tasks and reduce load on startup
factory.setStartupDelay(30);
return factory;
}
示例3: schedulerFactory
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setSchedulerName("Sentry");
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties());
// this allows to update triggers in DB when updating settings in config file:
factory.setOverwriteExistingJobs(true);
return factory;
}
示例4: createSchedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
/**
* 創建調度服務
* 每一個批次啟動後,創建一個調度服務
*/
public SchedulerFactoryBean createSchedulerFactoryBean(BatchRunConfDto conf, ResourceManagement drm) throws Exception {
this.conf = conf;
this.jobKeyStatusService = drm.getJobKeyStatusService();
this.argumentService = drm.getArgumentService();
getAllTaskForMap();
initGroupTaskMap(drm.getJobKeyList());
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
// 配置DataSource後,將會出現異常
// JobLauncher實例化對象無法序列化
// schedulerFactoryBean.setDataSource(dataSource);
schedulerFactoryBean.setSchedulerName(conf.getBatchId());
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(true);
schedulerFactoryBean.setAutoStartup(false);
// 獲取指定批次的所有任務Job
ArrayList<SimpleTrigger> arrayList = new ArrayList<SimpleTrigger>();
for (String jobId : jobKeyStatusService.getAllJob().keySet()) {
SimpleTrigger simpleTrigger = createSimpleTrigger(jobId);
schedulerFactoryBean.setTriggers(simpleTrigger);
arrayList.add(simpleTrigger);
}
SimpleTrigger[] simpleTriggers = new SimpleTrigger[arrayList.size()];
for (int i = 0; i < arrayList.size(); i++) {
simpleTriggers[i] = arrayList.get(i);
}
schedulerFactoryBean.setTriggers(simpleTriggers);
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.getScheduler().pauseAll();
schedulerFactoryBean.start();
return schedulerFactoryBean;
}
示例5: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
//quartz參數
Properties prop = new Properties();
prop.put("org.quartz.scheduler.instanceName", "JxteleScheduler");
prop.put("org.quartz.scheduler.instanceId", "AUTO");
//線程池配置
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount", "20");
prop.put("org.quartz.threadPool.threadPriority", "5");
//JobStore配置
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
//集群配置
prop.put("org.quartz.jobStore.isClustered", "true");
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop);
factory.setSchedulerName("RenrenScheduler");
//延時啟動
factory.setStartupDelay(30);
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
//可選,QuartzScheduler 啟動時更新己存在的Job,這樣就不用每次修改targetObject後刪除qrtz_job_details表對應記錄了
factory.setOverwriteExistingJobs(true);
//設置自動啟動,默認為true
factory.setAutoStartup(true);
return factory;
}
示例6: mainScheduler
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean(name = "mainScheduler")
public SchedulerFactoryBean mainScheduler(DelegatingQuartzJobFactory jobFactory,
@Qualifier("quartzProperties") Properties quartzProperties,
@Value("#{'${cronyx.passive}'=='true'}") boolean passive,
@Qualifier("cronyxDataSource") DataSource dataSource){
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties);
factory.setDataSource(dataSource);
factory.setAutoStartup(!passive);
factory.setSchedulerName(quartzProperties.getProperty(PROP_SCHED_INSTANCE_NAME));
return factory;
}
示例7: autoSchedulerFactory
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
public SchedulerFactoryBean autoSchedulerFactory(ApplicationContext applicationContext, JobFactory jobFactory,
QuartzSchedulerProperties properties, @Qualifier(QUARTZ_PROPERTIES_BEAN_NAME) Properties quartzProperties) {
LOGGER.debug("creating SchedulerFactory");
SchedulerFactoryBean factory = BeanUtils.instantiateClass(SchedulerFactoryBean.class);
factory.setApplicationContext(applicationContext);
factory.setJobFactory(jobFactory);
Persistence persistenceSettings = properties.getPersistence();
if (persistenceSettings.isPersisted()) {
factory.setDataSource(getDataSource(applicationContext, persistenceSettings));
if (persistenceSettings.isUsePlatformTxManager()) {
PlatformTransactionManager txManager = getTransactionManager(applicationContext);
if (null != txManager) {
factory.setTransactionManager(txManager);
}
}
}
SchedulerFactory factorySettings = properties.getSchedulerFactory();
factory.setSchedulerName(factorySettings.getSchedulerName());
factory.setPhase(factorySettings.getPhase());
factory.setStartupDelay(factorySettings.getStartupDelay());
factory.setAutoStartup(factorySettings.isAutoStartup());
factory.setWaitForJobsToCompleteOnShutdown(factorySettings.isWaitForJobsToCompleteOnShutdown());
factory.setOverwriteExistingJobs(factorySettings.isOverwriteExistingJobs());
factory.setExposeSchedulerInRepository(factorySettings.isExposeSchedulerInRepository());
factory.setQuartzProperties(quartzProperties);
Collection<Trigger> triggers = getTriggers(applicationContext);
if (null != triggers && !triggers.isEmpty()) {
factory.setTriggers(triggers.toArray(new Trigger[triggers.size()]));
LOGGER.info("staring scheduler factory with " + triggers.size() + " job triggers");
} else {
LOGGER.info("staring scheduler factory with 0 job triggers");
}
QuartzSchedulerFactoryOverrideHook hook = getQuartzSchedulerFactoryOverrideHook(applicationContext);
if (null != hook) {
factory = hook.override(factory, properties, quartzProperties);
}
return factory;
}
開發者ID:andrehertwig,項目名稱:spring-boot-starter-quartz,代碼行數:50,代碼來源:QuartzSchedulerAutoConfiguration.java