1414import com .lastcommit .piilot .global .util .AesEncryptor ;
1515import lombok .RequiredArgsConstructor ;
1616import lombok .extern .slf4j .Slf4j ;
17- import org .springframework .scheduling .annotation .Async ;
1817import org .springframework .stereotype .Service ;
1918import org .springframework .transaction .annotation .Transactional ;
2019
@@ -38,6 +37,7 @@ public class FileScanService {
3837 private final FileEncryptionChecker fileEncryptionChecker ;
3938 private final FileAiServerClient fileAiServerClient ;
4039 private final AesEncryptor aesEncryptor ;
40+ private final FileScanAsyncExecutor fileScanAsyncExecutor ;
4141
4242 @ Transactional
4343 public FileScanResponseDTO startScan (Long connectionId ) {
@@ -68,26 +68,14 @@ public FileScanResponseDTO startScan(Long connectionId) {
6868 .build ();
6969 scanHistory = scanHistoryRepository .save (scanHistory );
7070
71- // 6. Start async scan
72- executeScanAsync (connectionId , scanHistory .getId ());
71+ // 6. Start async scan (별도 빈을 통해 호출해야 @Async 프록시가 동작함)
72+ fileScanAsyncExecutor . executeScanAsync (connectionId , scanHistory .getId ());
7373
7474 return FileScanResponseDTO .from (scanHistory );
7575 }
7676
77- @ Async ("fileScanExecutor" )
78- public void executeScanAsync (Long connectionId , Long scanHistoryId ) {
79- log .info ("Starting file scan for connectionId={}" , connectionId );
80-
81- try {
82- executeScan (connectionId , scanHistoryId );
83- } catch (Exception e ) {
84- log .error ("File scan failed for connectionId={}: {}" , connectionId , e .getMessage (), e );
85- markScanFailed (scanHistoryId );
86- } finally {
87- // 스캔 완료/실패 시 isScanning = false
88- markScanStopped (connectionId );
89- }
90- }
77+ // executeScanAsync는 FileScanAsyncExecutor로 이동됨
78+ // (같은 클래스 내 @Async 자기호출은 Spring 프록시를 거치지 않아 동기 실행됨)
9179
9280 @ Transactional
9381 public void markScanStopped (Long connectionId ) {
0 commit comments