Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.dstech.cloud.configuration;
- import java.util.concurrent.Executor;
- import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
- import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.scheduling.annotation.AsyncConfigurer;
- import org.springframework.scheduling.annotation.EnableAsync;
- import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
- import it.dstech.cloud.beans.TestAsync;
- @Configuration
- @EnableAsync
- public class AsyncConfig implements AsyncConfigurer{
- @Bean
- public TestAsync testAsyncBean() {
- return new TestAsync();
- }
- @Override
- public Executor getAsyncExecutor() {
- ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
- taskExecutor.setMaxPoolSize(10);
- taskExecutor.setCorePoolSize(10);
- taskExecutor.setQueueCapacity(500);
- taskExecutor.setThreadNamePrefix("C2CExecutor-");
- taskExecutor.initialize();
- return taskExecutor;
- }
- @Override
- public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
- return new SimpleAsyncUncaughtExceptionHandler();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement