-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/swm_nm/morandi/config/async/AsyncConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package swm_nm.morandi.config.async; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.task.TaskExecutor; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
@Configuration | ||
@EnableAsync | ||
public class AsyncConfig { | ||
|
||
@Bean(name = "taskExecutor") | ||
public TaskExecutor taskExecutor() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(5); // 기본 스레드 풀 크기 | ||
executor.setMaxPoolSize(10); // 최대 스레드 풀 크기 | ||
executor.setQueueCapacity(25); // 큐의 용량 | ||
executor.setThreadNamePrefix("Async-"); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/swm_nm/morandi/domain/codeSubmit/controller/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package swm_nm.morandi.domain.codeSubmit.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import swm_nm.morandi.domain.codeSubmit.service.TestService; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class TestController { | ||
|
||
private final TestService testService; | ||
|
||
@PostMapping("/hello-world/{value}") | ||
public String getData(@PathVariable("value") Integer value) throws InterruptedException { | ||
return testService.test(value); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/swm_nm/morandi/domain/codeSubmit/service/TestService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package swm_nm.morandi.domain.codeSubmit.service; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class TestService { | ||
public String test(int value) throws InterruptedException { | ||
System.out.println("Response Message SSEID : " + 1 + " Count : " + value); | ||
return "hello"; | ||
} | ||
} |