Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.stream.Collectors;

import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.transaction.event.TransactionalEventListener;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class ArticleKeywordEventListener { // TODO : 리팩터링 필요 (비즈
private final KeywordService keywordService;
private final ArticleRepository articleRepository;

@Async
@TransactionalEventListener
public void onKeywordRequest(ArticleKeywordEvent event) {
Map<Integer, String> matchedKeywordByUserId = event.matchedKeywordByUserId();
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/in/koreatech/koin/global/config/AsyncConfig.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package in.koreatech.koin.global.config;

import static java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
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 lombok.extern.slf4j.Slf4j;

Expand All @@ -16,7 +19,14 @@ public class AsyncConfig implements AsyncConfigurer {

@Override
public Executor getAsyncExecutor() {
return null;
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(5);
executor.setQueueCapacity(20);
executor.setThreadNamePrefix("AsyncExecutor-");
executor.setRejectedExecutionHandler(new CallerRunsPolicy());
executor.initialize();
return executor;
}

@Override
Expand Down
Loading