Skip to content

Commit

Permalink
refactor: Async ThreadPool 설정 30 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim0914 committed Jan 10, 2024
1 parent 0b3b9c8 commit 9fc3d3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ public class TestService {
// log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName());
// }

public void sendWaterNotificationAsyncRampTest() {
List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
List<NotificationEvent> events = petPlants.stream()
.map(plant -> NotificationEvent.builder()
.title(plant.getNickname())
.body("(테스트 중) 물을 줄 시간이에요!")
.deviceToken(plant.getMember().getDeviceToken())
.build()
).toList();

log.info("비동기 테스트 램프업 시작");
for (int i = 0; i < 40; i++) {
NotificationEvent notificationEvent = events.get(i);
publisher.publishEvent(notificationEvent);
}
}

public void sendWaterNotificationAsyncTest() {
List<PetPlant> petPlants = petPlantRepository.findAllByMemberId(7L);
List<NotificationEvent> events = petPlants.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class TestController {
// return ResponseEntity.ok("알림 기능 테스트 성공");
// }

@GetMapping("/notifications/ramp")
public ResponseEntity<String> notificationRampTest() {
testService.sendWaterNotificationAsyncRampTest();
return ResponseEntity.ok("비동기 알림 기능 테스트 램프업 성공");
}

@GetMapping("/notifications/async")
public ResponseEntity<String> notificationAsyncTest() {
testService.sendWaterNotificationAsyncTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AsyncConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(20);
executor.setCorePoolSize(30);
// executor.setQueueCapacity(15);
// executor.setMaxPoolSize(200);
executor.setThreadNamePrefix("2024-Pium-Thread: ");
Expand Down

0 comments on commit 9fc3d3d

Please sign in to comment.