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


Java ThreadPoolTaskScheduler.schedule方法代码示例

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


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

示例1: initBackgroundJobs

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
protected void initBackgroundJobs(WebApplicationContext ctx) {
    try {
        IConfigurationService configurationService = ctx.getBean(IConfigurationService.class);
        IImportExportService importExportService = ctx.getBean(IImportExportService.class);
        IOperationsService operationsService = ctx.getBean(IOperationsService.class);
        
        jobScheduler = new ThreadPoolTaskScheduler();
        jobScheduler.setDaemon(true);
        jobScheduler.setThreadNamePrefix("background-job-");
        jobScheduler.setPoolSize(2);
        jobScheduler.initialize();

        TypedProperties properties = operationsService.findGlobalSetttingsAsProperties();
        if (properties.is(CONFIG_BACKUP_ENABLED, DEFAULT_CONFIG_BACKUP_ENABLED)) {
            jobScheduler.schedule(new BackupJob(importExportService, configurationService, operationsService, getConfigDir(false)),
                    new CronTrigger(
                            properties.get(CONFIG_BACKUP_CRON, DEFAULT_CONFIG_BACKUP_CRON)));
        }
        jobScheduler.scheduleAtFixedRate(() -> configurationService.doInBackground(), 600000);
    } catch (Exception e) {
        LoggerFactory.getLogger(getClass()).info("Failed to schedule  the backup job", e);
    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:24,代码来源:AppInitializer.java

示例2: runDeadlockFuture

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
/**
 * Runs deadlock guard task
 *
 * @param deadlockGuardTask
 *            deadlock guard task
 */
@SuppressWarnings("unchecked")
public void runDeadlockFuture(Runnable deadlockGuardTask) {
    if (deadlockFuture == null) {
        ThreadPoolTaskScheduler deadlockGuard = conn.getDeadlockGuardScheduler();
        if (deadlockGuard != null) {
            try {
                deadlockFuture = (ScheduledFuture<Runnable>) deadlockGuard.schedule(deadlockGuardTask, new Date(packet.getExpirationTime()));
            } catch (TaskRejectedException e) {
                log.warn("DeadlockGuard task is rejected for {}", sessionId, e);
            }
        } else {
            log.debug("Deadlock guard is null for {}", sessionId);
        }
    } else {
        log.warn("Deadlock future is already create for {}", sessionId);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:24,代码来源:ReceivedMessageTask.java

示例3: initGeoCache

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@PostConstruct
public void initGeoCache() {
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
    threadPoolTaskScheduler.setPoolSize(1);
    threadPoolTaskScheduler.afterPropertiesSet();
    threadPoolTaskScheduler.schedule(() -> {
        if (mongoTemplate.getCollection("geographical_area").count() == 0) {
            logger.info("Geo area cache is empty, initializing it");
            replicate();
        }
    }, new Date());
}
 
开发者ID:ozwillo,项目名称:ozwillo-portal,代码行数:13,代码来源:GeographicalAreaCache.java

示例4: start

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@PostConstruct
public void start() {
	Validate.notBlank(cronExpression);

	threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
	threadPoolTaskScheduler.setThreadNamePrefix("SpringCronJob");
	threadPoolTaskScheduler.initialize();

	threadPoolTaskScheduler.schedule(this, new CronTrigger(cronExpression));
}
 
开发者ID:Michaelleolee,项目名称:appengine,代码行数:11,代码来源:SpringCronJob.java


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