|
|
|
|
@ -3,12 +3,18 @@ package com.bsmlab.dfx.agent.task;
|
|
|
|
|
import com.bsmlab.dfx.agent.config.AgentConfigDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.config.AgentConfigReader;
|
|
|
|
|
import com.bsmlab.dfx.agent.config.datasource.SqlExecuteService;
|
|
|
|
|
import com.bsmlab.dfx.agent.listener.dto.AckDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.listener.dto.ReceiveMessageDto;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
@ -41,10 +47,13 @@ public class TaskExecutorService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
//TODO 수신한 메시지 파일을 찾지 못했으니 메시지 처리 불가. 로그 남기고 Ack.PROCESS_FAIL 전달
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
//TODO 수신한 메시지를 로드하지 못했으니 메시지 처리 불가. 로그 남기고 파일을 미처리 상태 경로로 옮기고 Ack.PROCESS_FAIL 전달
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
//TODO ReceiveMessageDto 변환 실패. 로그 남기고 파일을 미처리 상태 경로로 옮기고 Ack.PROCESS_FAIL 전달
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -53,4 +62,24 @@ public class TaskExecutorService {
|
|
|
|
|
public void processPostman() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ackDropBoxProcessResult(ReceiveMessageDto receiveMessageDto) {
|
|
|
|
|
AckDto ackDto = AckDto.builder().build();
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
HttpEntity<AckDto> bodyEntity = new HttpEntity<>(ackDto, httpHeaders);
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
//TODO sender 정보를 찾아야 함.
|
|
|
|
|
AgentConfigDto.KnownAgent knownAgent = agentConfigReader.getKnownAgent(receiveMessageDto.getSenderHostId());
|
|
|
|
|
String url = "https://" + knownAgent.getHostName() + "/telegram";
|
|
|
|
|
String response = restTemplate.postForObject("hostname", bodyEntity, String.class);
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
try {
|
|
|
|
|
AckDto responseAckDto = objectMapper.readValue(response, AckDto.class);
|
|
|
|
|
// 수신 메시지 처리 완료. 메시지 삭제
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
//TODO 처리 결과 Ack 파싱 실패. 로그 남기고 메시지 삭제
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|