当前位置: 首页>>代码示例>>Java>>正文


Java SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown方法代码示例

本文整理汇总了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown方法的具体用法?Java SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown怎么用?Java SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.scheduling.quartz.SchedulerFactoryBean的用法示例。


在下文中一共展示了SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) {
    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setApplicationContext(applicationContext);
    schedulerFactoryBean.setAutoStartup(schedulerProperties.isAutoStartup());
    schedulerFactoryBean.setDataSource(dataSource);
    schedulerFactoryBean.setTransactionManager(platformTransactionManager);
    schedulerFactoryBean.setOverwriteExistingJobs(schedulerProperties.isOverwriteExistingJobs());
    schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class);
    schedulerFactoryBean.setBeanName(schedulerProperties.getBeanName());
    schedulerFactoryBean.setJobFactory(jobFactory);
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown());
    schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties());
    schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay());
    schedulerFactoryBean.setCalendars(calendarMap);
    schedulerFactoryBean.setSchedulerListeners(schedulerListeners);
    return schedulerFactoryBean;
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:19,代码来源:ScheduleAutoConfiguration.java

示例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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:21,代码来源:QuartzConfig.java

示例3: 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;
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:39,代码来源:BatchSchedulerConfig.java

示例4: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
    SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
    scheduler.setApplicationContextSchedulerContextKey("applicationContext");
    scheduler.setConfigLocation(new ClassPathResource("quartz.properties"));
    // scheduler.setAutoStartup(false);  // to not automatically start after startup
    scheduler.setWaitForJobsToCompleteOnShutdown(true);
    return scheduler;
}
 
开发者ID:nikos,项目名称:springboot-quartz-mongodb,代码行数:10,代码来源:QuartzConfiguration.java

示例5: init

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  ComponentInfo info = new ComponentInfo(Scheduler.class, getClassifier());
  
  Properties quartzProperties = new Properties();
  quartzProperties.setProperty(StdSchedulerFactory.PROP_SCHED_JMX_EXPORT, "true");
  quartzProperties.setProperty(StdSchedulerFactory.PROP_SCHED_SKIP_UPDATE_CHECK, "true");
  
  SchedulerFactoryBean schedulerBean = new SchedulerFactoryBean();
  schedulerBean.setWaitForJobsToCompleteOnShutdown(true);
  schedulerBean.setQuartzProperties(quartzProperties);
      
  repo.registerComponent(info, schedulerBean);
  repo.registerLifecycle(schedulerBean);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:16,代码来源:SchedulerComponentFactory.java

示例6: init

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
 * Creates the Spring {@code SchedulerFactoryBean}.
 */
@PostConstruct
public void init() {
    schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setQuartzProperties(schedulerProperties);
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(getBooleanWithDefault(schedulerProperties.getProperty("scheduler.waitForJobsToCompleteOnShutdown"), true));
    schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
    schedulerFactoryBean.setApplicationContext(applicationContext);
    try {
        schedulerFactoryBean.afterPropertiesSet();
        schedulerFactoryBean.getScheduler().start();
    } catch (Exception e) {
        throw new SchedulerInstantiationException("Failed to instantiate scheduler with configuration from quartz.properties", e);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:18,代码来源:MotechSchedulerFactoryBean.java

示例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

示例8: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(){
    SchedulerFactoryBean res = new SchedulerFactoryBean();
    res.setWaitForJobsToCompleteOnShutdown(false);
    return res;
}
 
开发者ID:datenstrudel,项目名称:bulbs-core,代码行数:7,代码来源:InfrastructureServicesConfig.java


注:本文中的org.springframework.scheduling.quartz.SchedulerFactoryBean.setWaitForJobsToCompleteOnShutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。