Async Config - redutan/redutan.github.io GitHub Wiki
/**
* 비동기 설정
*
* @author myeongju.jung
*/
@Configuration
@EnableAsync(proxyTargetClass = true)
@Slf4j
public class AsyncConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(200);
executor.setMaxPoolSize(200);
executor.setQueueCapacity(400);
executor.setThreadNamePrefix("MyAppAsync-");
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
executor.initialize();
return executor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return (Throwable ex, Method method, Object... params) ->
log.error("{}[ASYNC] {}\n{}\n{}", PREFIX_FOR_ALERT, ex.getMessage(), method, params, ex);
}
}