|
@@ -3,9 +3,12 @@ package com.ruoyi.framework.config;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+
|
|
|
+import com.ruoyi.framework.manager.VisiableThreadPoolTaskExecutor;
|
|
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import com.ruoyi.common.utils.Threads;
|
|
|
|
|
@@ -15,6 +18,7 @@ import com.ruoyi.common.utils.Threads;
|
|
|
* @author ruoyi
|
|
|
**/
|
|
|
@Configuration
|
|
|
+@EnableAsync
|
|
|
public class ThreadPoolConfig
|
|
|
{
|
|
|
|
|
@@ -29,16 +33,23 @@ public class ThreadPoolConfig
|
|
|
|
|
|
private int keepAliveSeconds = 300;
|
|
|
|
|
|
+
|
|
|
+ private String threadNamePrefix="async-service-";
|
|
|
+
|
|
|
@Bean(name = "threadPoolTaskExecutor")
|
|
|
public ThreadPoolTaskExecutor threadPoolTaskExecutor()
|
|
|
{
|
|
|
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
+
|
|
|
+ ThreadPoolTaskExecutor executor = new VisiableThreadPoolTaskExecutor();
|
|
|
executor.setMaxPoolSize(maxPoolSize);
|
|
|
executor.setCorePoolSize(corePoolSize);
|
|
|
executor.setQueueCapacity(queueCapacity);
|
|
|
executor.setKeepAliveSeconds(keepAliveSeconds);
|
|
|
+ executor.setThreadNamePrefix(threadNamePrefix);
|
|
|
|
|
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
|
|
+
|
|
|
+ executor.initialize();
|
|
|
return executor;
|
|
|
}
|
|
|
|