👉 에러
비동기(@Async) 실행을 위한 TaskExecutor를 찾지 못하는 문제
NFO 13248 --- .s.a.AnnotationAsyncExecutionInterceptor :
More than one TaskExecutor bean found within the context, and none is named 'taskExecutor'.
Mark one of them as primary or name it 'taskExecutor' (possibly as an alias) in order to use it for async processing:
[clientInboundChannelExecutor, clientOutboundChannelExecutor, brokerChannelExecutor]
👉 원인
- spring이 WebSocket(STOMP) 관련 TaskExecutor(clientInboundChannelExecutor, clientOutboundChannelExecutor, brokerChannelExecutor)를 자동으로 생성하고 있음.
- 하지만 @Async에서 사용할 기본 TaskExecutor가 taskExecutor로 명시되지 않아서 어떤 것을 사용할지 결정하지 못함.
🚀 해결 방법
taskExecutor를 명시적으로 지정
1️⃣ AsyncConfig 클래스를 만들어 TaskExecutor를 명확하게 지정
@Bean(name = "mailExecutor")
public Executor mailExecutor()
2️⃣ 비동기 실행 시 명시적으로 taskExecutor 사용
@Async("mailExecutor")
public void sendMailWithPdf(String novelId, User user,List<String> fileNames, List<byte[]> fileDataList) throws MessagingException {
'TIL > 트러블슈팅' 카테고리의 다른 글
[Chocolatey] An existing Chocolatey installation was detected. (0) | 2025.01.22 |
---|---|
[SpringBoot] failed to lazily initialize a collection of role: could not initialize proxy - no Session (0) | 2024.02.29 |
[Node] getaddrinfo ENOTFOUND your-proxy-server (0) | 2024.02.28 |
[SpringBoot] No acceptable representation (1) | 2024.02.09 |
[Docker] Docker failed to initialize (0) | 2023.12.12 |