Skip to content

Commit

Permalink
refactor : 메일 전송 비동기로 보내도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
seulgi99 committed Jul 4, 2024
1 parent 753de5c commit bcf9dc6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableCaching
@EnableScheduling
@EnableAsync
@SpringBootApplication
public class LikelionClientApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class HackathonApplyEmailContent {
<tr>
<td style="width: 20px"></td>
<td>
<img src="https://drive.google.com/uc?id=17_m34Zn_PnbB_R5HjzJJe0k1Lh4BX04w" width="300" height="100" style="max-width: 100%; height: auto; vertical-align: top">
<img src="https://drive.google.com/thumbnail?id=17_m34Zn_PnbB_R5HjzJJe0k1Lh4BX04w&sz=s4000" width="300" height="100" style="max-width: 100%; height: auto; vertical-align: top" loading="eager">
</td>
</tr>
<tr>
Expand Down
23 changes: 23 additions & 0 deletions likelion-core/src/main/java/likelion/univ/config/AsyncConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package likelion.univ.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 = "threadPoolTaskExecutor")
public Executor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(30);
executor.setQueueCapacity(50);
executor.setThreadNamePrefix("LIKELION_ASYNC");
executor.initialize();
return executor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import likelion.univ.email.sender.EmailContent;
import likelion.univ.email.sender.EmailSender;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -28,6 +29,7 @@ public class AzureEmailSender implements EmailSender {

private final AzureCommunicationProperties properties;

@Async
@Override
public void send(EmailContent emailContent) {
EmailClient emailClient = setUpEmailClient();
Expand Down

0 comments on commit bcf9dc6

Please sign in to comment.