本文整理汇总了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);
}
}
示例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);
}
}
示例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());
}
示例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));
}