|
|
|
|
@ -226,6 +226,7 @@ public class MessageUtils {
|
|
|
|
|
AgentConfigDto.KnownAgent recipientAgent = agentConfigReader.getKnownAgent(receiveMessageDto.getRecipientHostId());
|
|
|
|
|
String targetHostId = recipientAgent.getRoutingHostIdList().get(0);
|
|
|
|
|
AgentConfigDto.KnownAgent knownAgent = agentConfigReader.getKnownAgent(targetHostId);
|
|
|
|
|
String protocol = knownAgent.isSslEnabled() ? "https://" : "http://";
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")"
|
|
|
|
|
@ -234,7 +235,7 @@ public class MessageUtils {
|
|
|
|
|
);
|
|
|
|
|
HttpEntity<ReceiveMessageDto> bodyEntity = new HttpEntity<>(receiveMessageDto, httpHeaders);
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/listen";
|
|
|
|
|
String url = protocol + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/listen";
|
|
|
|
|
String response = restTemplate.postForObject(url, bodyEntity, String.class);
|
|
|
|
|
AckDto ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {});
|
|
|
|
|
return ackDto;
|
|
|
|
|
@ -254,6 +255,7 @@ public class MessageUtils {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AgentConfigDto.KnownAgent knownAgent = agentConfigReader.getKnownAgent(targetHostId);
|
|
|
|
|
String protocol = knownAgent.isSslEnabled() ? "https://" : "http://";
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")"
|
|
|
|
|
@ -262,7 +264,7 @@ public class MessageUtils {
|
|
|
|
|
);
|
|
|
|
|
HttpEntity<ReceiveMessageDto> bodyEntity = new HttpEntity<>(receiveMessageDto, httpHeaders);
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/listen";
|
|
|
|
|
String url = protocol + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/listen";
|
|
|
|
|
String response = restTemplate.postForObject(url, bodyEntity, String.class);
|
|
|
|
|
AckDto ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {});
|
|
|
|
|
return ackDto;
|
|
|
|
|
@ -271,6 +273,7 @@ public class MessageUtils {
|
|
|
|
|
public static AckDto alive(AgentConfigReader agentConfigReader, AgentConfigDto.KnownAgent knownAgent) throws JsonProcessingException {
|
|
|
|
|
String messageUuid = UUID.randomUUID().toString();
|
|
|
|
|
CommandDto commandDto = CommandDto.builder().commandType(CommandDto.CommandType.ALIVE).messageUuid(messageUuid).build();
|
|
|
|
|
String protocol = knownAgent.isSslEnabled() ? "https://" : "http://";
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
httpHeaders.set("User-Agent", agentConfigReader.getApplicationName() + ", version: " + agentConfigReader.getApplicationVersion() + "(" + agentConfigReader.getApplicationCommitId() + ")"
|
|
|
|
|
@ -279,7 +282,7 @@ public class MessageUtils {
|
|
|
|
|
);
|
|
|
|
|
HttpEntity<CommandDto> bodyEntity = new HttpEntity<>(commandDto, httpHeaders);
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";
|
|
|
|
|
String url = protocol + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";
|
|
|
|
|
log.debug("StatusChecker to {} send a message UUID {}", knownAgent.getHostName(), messageUuid);
|
|
|
|
|
String response = "";
|
|
|
|
|
AckDto ackDto = null;
|
|
|
|
|
|