feat: mail 이메일 인증 비동기 처리 추가
This commit is contained in:
parent
5be49ad81c
commit
365b12ad9e
@ -3,7 +3,9 @@ package com.edufocus.edufocus;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@EnableAsync
|
||||
@EnableJpaAuditing
|
||||
@SpringBootApplication
|
||||
public class EdufocusApplication {
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.edufocus.edufocus.global.config;
|
||||
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class AsyncConfig implements AsyncConfigurer {
|
||||
|
||||
@Override
|
||||
@Bean(name = "mailExecutor")
|
||||
public Executor getAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setQueueCapacity(500);
|
||||
executor.setThreadNamePrefix("MailExecutor-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return AsyncConfigurer.super.getAsyncUncaughtExceptionHandler();
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Random;
|
||||
@ -27,6 +28,7 @@ public class MailServiceImpl implements MailService {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
@Async("mailExecutor")
|
||||
public void sendMail(String email) {
|
||||
String code = createRandomCode();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user