Skip to content

Commit

Permalink
refactor: Async ThreadPool설정 클래스 위치 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
xxeol2 committed Oct 4, 2023
1 parent 49c15e6 commit e253317
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
22 changes: 22 additions & 0 deletions backend/src/main/java/com/festago/config/AsyncConfig.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
package com.festago.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;

@EnableAsync
@Configuration
public class AsyncConfig {

private static final String DEFAULT_EXECUTOR_NAME = "taskExecutor";
public static final String FCM_EXECUTOR_NAME = "fcmExecutor";

@Bean(name = DEFAULT_EXECUTOR_NAME)
public Executor defaultExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(8);
executor.initialize();
return executor;
}

@Bean(name = FCM_EXECUTOR_NAME)
public Executor fcmExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setQueueCapacity(10);
executor.initialize();
return executor;
}
}
22 changes: 0 additions & 22 deletions backend/src/main/java/com/festago/config/SchedulingConfig.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
package com.festago.config;

import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@EnableScheduling
public class SchedulingConfig {

private static final String DEFAULT_EXECUTOR_NAME = "taskExecutor";
public static final String FCM_EXECUTOR_NAME = "fcmExecutor";

@Bean(name = DEFAULT_EXECUTOR_NAME)
public Executor defaultExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(8);
executor.initialize();
return executor;
}

@Bean(name = FCM_EXECUTOR_NAME)
public Executor fcmExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setQueueCapacity(10);
executor.initialize();
return executor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.festago.common.exception.ErrorCode;
import com.festago.common.exception.InternalServerException;
import com.festago.common.utils.AsyncBatchExecutor;
import com.festago.config.SchedulingConfig;
import com.festago.config.AsyncConfig;
import com.festago.fcm.application.FcmClient;
import com.festago.fcm.domain.FCMChannel;
import com.festago.fcm.dto.FcmPayload;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class FcmClientImpl implements FcmClient {
private final Executor taskExecutor;

public FcmClientImpl(FirebaseMessaging firebaseMessaging,
@Qualifier(SchedulingConfig.FCM_EXECUTOR_NAME) Executor taskExecutor) {
@Qualifier(AsyncConfig.FCM_EXECUTOR_NAME) Executor taskExecutor) {
this.firebaseMessaging = firebaseMessaging;
this.taskExecutor = taskExecutor;
}
Expand Down

0 comments on commit e253317

Please sign in to comment.