|
@@ -22,12 +22,14 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
|
|
import org.apache.dolphinscheduler.alert.api.HttpServiceRetryStrategy;
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
|
|
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpStatus;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
@@ -82,15 +84,21 @@ public final class WebexTeamsSender {
|
|
|
HttpClients.custom().setRetryHandler(HttpServiceRetryStrategy.retryStrategy).build();
|
|
|
|
|
|
try {
|
|
|
- HttpPost httpPost = constructHttpPost(getMessage(alertData), botAccessToken);
|
|
|
+ WebexMessage message = getMessage(alertData);
|
|
|
+ HttpPost httpPost = constructHttpPost(message, botAccessToken);
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ HttpEntity entity = response.getEntity();
|
|
|
+ String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8);
|
|
|
try {
|
|
|
if (statusCode == HttpStatus.SC_OK) {
|
|
|
alertResult.setStatus("true");
|
|
|
alertResult.setMessage("send webex teams alert success");
|
|
|
} else {
|
|
|
+ alertResult.setMessage(String.format(
|
|
|
+ "send webex teams alert error, message: %s, statusCode: %s, responseContent: %s", message,
|
|
|
+ statusCode, responseContent));
|
|
|
log.info("send webex teams alert fail, statusCode : {}", statusCode);
|
|
|
}
|
|
|
} finally {
|