Skip to content
정명주(myeongju.jung) edited this page Jun 28, 2019 · 2 revisions
/**
 * 비동기 설정
 *
 * @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);
    }
}
Clone this wiki locally