|
@@ -1,8 +1,12 @@
|
|
|
package com.sqx.scheduler.config;
|
|
package com.sqx.scheduler.config;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
+import org.springframework.scheduling.annotation.AsyncConfigurer;
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.concurrent.Executor;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 调度配置
|
|
* 调度配置
|
|
@@ -14,5 +18,16 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
@EnableAsync
|
|
@EnableAsync
|
|
|
@EnableScheduling
|
|
@EnableScheduling
|
|
|
@Configuration
|
|
@Configuration
|
|
|
-public class ScheduledConfig {
|
|
|
|
|
|
|
+public class ScheduledConfig implements AsyncConfigurer {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Executor getAsyncExecutor() {
|
|
|
|
|
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
|
|
|
+ executor.setCorePoolSize(10);
|
|
|
|
|
+ executor.setMaxPoolSize(20);
|
|
|
|
|
+ executor.setQueueCapacity(50);
|
|
|
|
|
+ executor.setKeepAliveSeconds(60);
|
|
|
|
|
+ executor.initialize();
|
|
|
|
|
+ return executor;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|