Blame view

src/main/java/com/batch/config/AsyncConfig.java 1.42 KB
8dc487b1   함상기   Init Version - 20...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  package com.batch.config;

  

  import java.util.concurrent.Executor;

  

  import org.springframework.context.annotation.Bean;

  import org.springframework.context.annotation.Configuration;

  import org.springframework.scheduling.annotation.EnableAsync;

  import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

  

  @Configuration

  @EnableAsync

  public class AsyncConfig {

  

      @Bean(name = "commAsync")

      public Executor commAsyncExecutor() {

          ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();

          executor.setCorePoolSize(5);

          executor.setMaxPoolSize(50);

          executor.setKeepAliveSeconds(30);

          executor.setAllowCoreThreadTimeOut(true);

          executor.setWaitForTasksToCompleteOnShutdown(true);

          executor.setThreadNamePrefix("commAsync-processor-");

          executor.initialize();

          

          return executor;

      }

  

  	@Bean(name = "aiAsync")

      public Executor aiAsyncExecutor() {

          ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();

          executor.setCorePoolSize(50);

          executor.setMaxPoolSize(100);

          executor.setQueueCapacity(1000);

          executor.setKeepAliveSeconds(30);

          executor.setAllowCoreThreadTimeOut(true);

          executor.setWaitForTasksToCompleteOnShutdown(true);

          executor.setThreadNamePrefix("aiAsync-processor-");

          executor.initialize();

          

          return executor;

      }

  }