|
|
|
|
@ -16,6 +16,8 @@ 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.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
|
|
import org.springframework.scheduling.support.CronTrigger;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
@ -24,14 +26,18 @@ import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class DropBoxTaskExecutorService {
|
|
|
|
|
private final ThreadPoolTaskExecutor dropBoxProcessorThreadPoolTaskExecutor;
|
|
|
|
|
private final ThreadPoolTaskScheduler dropBoxProcessorThreadPoolTaskScheduler;
|
|
|
|
|
private final AgentConfigReader agentConfigReader;
|
|
|
|
|
private final SqlExecuteService sqlExecuteService;
|
|
|
|
|
private final DropBoxService dropBoxService;
|
|
|
|
|
@ -156,8 +162,25 @@ public class DropBoxTaskExecutorService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void run() {
|
|
|
|
|
try {
|
|
|
|
|
String messageFilePath = dropBoxService.poll();
|
|
|
|
|
if(StringUtils.isNotBlank(messageFilePath)) {
|
|
|
|
|
log.info("dropBoxProcessThread {} process a message {}", Thread.currentThread().getName(), messageFilePath);
|
|
|
|
|
this.processDropBox(messageFilePath);
|
|
|
|
|
}
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("{}", e, e);
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void launch() { // 실행확인됨
|
|
|
|
|
log.debug("{} launch", this.getClass().getName());
|
|
|
|
|
ScheduledFuture<?> scheduledFuture = dropBoxProcessorThreadPoolTaskScheduler.scheduleWithFixedDelay(this::run, Duration.ofMillis(10));
|
|
|
|
|
/*
|
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
|
try {
|
|
|
|
|
log.info("dropBoxProcessThread run {}", Thread.currentThread().getName());
|
|
|
|
|
@ -174,6 +197,7 @@ public class DropBoxTaskExecutorService {
|
|
|
|
|
for(int i = 0; i < this.dropBoxProcessorThreadPoolTaskExecutor.getCorePoolSize(); i++) {
|
|
|
|
|
this.dropBoxProcessorThreadPoolTaskExecutor.execute(runnable);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|