新增 动态消息转历史数据 定时器功能
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user