|
|
|
|
@ -15,6 +15,7 @@ import org.springframework.http.HttpEntity;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
@ -30,6 +31,7 @@ import java.util.Map;
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class DropBoxTaskExecutorService {
|
|
|
|
|
private final ThreadPoolTaskExecutor dropBoxProcessorThreadPoolTaskExecutor;
|
|
|
|
|
private final AgentConfigReader agentConfigReader;
|
|
|
|
|
private final SqlExecuteService sqlExecuteService;
|
|
|
|
|
private final DropBoxService dropBoxService;
|
|
|
|
|
@ -40,7 +42,7 @@ public class DropBoxTaskExecutorService {
|
|
|
|
|
* @param messageFilePath 메지시 파일 절대 경로
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Async("dropBoxProcessorThreadPoolTaskExecutor")
|
|
|
|
|
// @Async("dropBoxProcessorThreadPoolTaskExecutor")
|
|
|
|
|
public void processDropBox(String messageFilePath) {
|
|
|
|
|
ReceiveMessageDto receiveMessageDto = ReceiveMessageDto.builder().build();
|
|
|
|
|
ReceiveMessageDto.ProcessStatus processStatus;
|
|
|
|
|
@ -155,18 +157,22 @@ public class DropBoxTaskExecutorService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void launch() { // 실행확인됨
|
|
|
|
|
log.debug("{} @PostConstruct Run", this.getClass().getName());
|
|
|
|
|
while(true) {
|
|
|
|
|
log.debug("{} launch", this.getClass().getName());
|
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
log.info("dropBoxProcessThread run {}", Thread.currentThread().getName());
|
|
|
|
|
String messageFilePath = dropBoxService.poll();
|
|
|
|
|
if(StringUtils.isNotBlank(messageFilePath)) {
|
|
|
|
|
this.processDropBox(messageFilePath);
|
|
|
|
|
}
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("{}", e, e);
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
for(int i = 0; i < this.dropBoxProcessorThreadPoolTaskExecutor.getCorePoolSize(); i++) {
|
|
|
|
|
this.dropBoxProcessorThreadPoolTaskExecutor.execute(runnable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|