api-修改线程池内容
This commit is contained in:
@@ -25,7 +25,6 @@ public class NettyWeiXinApplication {
|
||||
* @param args 启动参数
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// SpringApplication.run(NettyWeiXinApplication.class, args);
|
||||
ConfigurableApplicationContext context = SpringApplication.run(NettyWeiXinApplication.class, args);
|
||||
SpringContextHolder.setContext(context);
|
||||
//启动netty
|
||||
@@ -33,33 +32,4 @@ public class NettyWeiXinApplication {
|
||||
bootService.run();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目可能又使用计划任务的
|
||||
*/
|
||||
// private int corePoolSize = 5;//线程池维护线程的最少数量
|
||||
//
|
||||
// private int maxPoolSize = 15;//线程池维护线程的最大数量
|
||||
//
|
||||
// private int queueCapacity = 5; //缓存队列
|
||||
//
|
||||
// private int keepAlive = 60;//允许的空闲时间
|
||||
// @Bean("scheduledExecutorService")
|
||||
// public ScheduledExecutorService initScheduledExecutorService() {
|
||||
// ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(400,
|
||||
// new BasicThreadFactory.Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());
|
||||
// return executorService;
|
||||
// }
|
||||
// @Bean
|
||||
// public Executor executor() {
|
||||
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// executor.setCorePoolSize(corePoolSize);
|
||||
// executor.setMaxPoolSize(maxPoolSize);
|
||||
// executor.setQueueCapacity(queueCapacity);
|
||||
// executor.setThreadNamePrefix("mqExecutor-");
|
||||
// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||
// executor.setKeepAliveSeconds(keepAlive);
|
||||
// executor.initialize();
|
||||
// return executor;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sv.api;
|
||||
|
||||
import com.sv.api.interceptor.AccessTokensInterceptorNew;
|
||||
import com.sv.api.interceptor.PlatformInterceptor;
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
@@ -10,6 +11,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* Spring Mvc Configuration
|
||||
@@ -42,4 +45,16 @@ public class InterceptorConfigurer extends WebMvcConfigurerAdapter {
|
||||
public Executor initExecutor(){
|
||||
return Executors.newFixedThreadPool(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟任务
|
||||
* @return
|
||||
*/
|
||||
@Bean("scheduledExecutorService")
|
||||
public ScheduledExecutorService initScheduledExecutorService() {
|
||||
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(400,
|
||||
new BasicThreadFactory.Builder().namingPattern("netty-door-pool-%d").daemon(true).build());
|
||||
return executorService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user