1
|
package eu.dnetlib.parthenos;
|
2
|
|
3
|
import java.util.concurrent.Executor;
|
4
|
|
5
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
6
|
import org.springframework.context.annotation.Bean;
|
7
|
import org.springframework.context.annotation.Configuration;
|
8
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
9
|
import org.springframework.scheduling.annotation.EnableAsync;
|
10
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
11
|
|
12
|
/**
|
13
|
* Created by Alessia Bardi on 17/10/2017.
|
14
|
*
|
15
|
* @author Alessia Bardi
|
16
|
*/
|
17
|
@Configuration
|
18
|
@EnableAsync
|
19
|
public class AppConfig implements AsyncConfigurer {
|
20
|
|
21
|
@Override
|
22
|
@Bean
|
23
|
public Executor getAsyncExecutor() {
|
24
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
25
|
executor.setCorePoolSize(7);
|
26
|
executor.setMaxPoolSize(42);
|
27
|
executor.setQueueCapacity(11);
|
28
|
executor.setThreadNamePrefix("MyExecutor-");
|
29
|
//executor.initialize();
|
30
|
return executor;
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
35
|
return new ParthenosAsyncUncaughtExceptionHandler();
|
36
|
}
|
37
|
}
|