新增 动态消息转历史数据 定时器功能

This commit is contained in:
fanghongchao
2018-12-14 18:17:40 +08:00
parent 6ff3926429
commit 3070e8c551
9 changed files with 644 additions and 2 deletions
@@ -0,0 +1,38 @@
package com.gzzn.omms.msgexchangeapi.config;
import java.util.concurrent.Executor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* 定时器多线程配置
* @author fhc
*
*/
@Configuration
@EnableAsync
public class ScheduledAsyncConfig {
/*
此处成员变量应该使用@Value从配置中读取
*/
@Value("${scheduled.corePoolSize}")
private int corePoolSize;
@Value("${scheduled.maxPoolSize}")
private int maxPoolSize;
@Value("${scheduled.queueCapacity}")
private int queueCapacity;
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.initialize();
return executor;
}
}