private void httpSend(String ip) {
String url = CloudBusGlobalProperty.HTTP_CONTEXT_PATH.isEmpty() ? String.format("http://%s:%s%s",
ip, CloudBusGlobalProperty.HTTP_PORT, HTTP_BASE_URL) : String.format("http://%s:%s/%s/%s",
ip, CloudBusGlobalProperty.HTTP_PORT, CloudBusGlobalProperty.HTTP_CONTEXT_PATH, HTTP_BASE_URL);
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> req = new HttpEntity<>(CloudBusGson.toJson(msg), headers);
try {
ResponseEntity<String> rsp = new Retry<ResponseEntity<String>>() {
{
interval = 2;
}
@Override
@RetryCondition(onExceptions = {IOException.class, RestClientException.class, HttpClientErrorException.class})
protected ResponseEntity<String> call() {
return http.exchange(url, HttpMethod.POST, req, String.class);
}
}.run();
if (!rsp.getStatusCode().is2xxSuccessful()) {
replyErrorIfNeeded(operr("HTTP ERROR, status code: %s, body: %s", rsp.getStatusCode(), rsp.getBody()));
}
} catch (OperationFailureException e) {
replyErrorIfNeeded(e.getErrorCode());
} catch (Throwable e) {
replyErrorIfNeeded(operr(e.getMessage()));
}
}