xueyiming 1 місяць тому
батько
коміт
2a8e2cfd09

+ 24 - 17
common-module/src/main/java/com/tzld/piaoquan/growth/common/component/ProxyHttpPoolClient.java

@@ -71,24 +71,31 @@ public class ProxyHttpPoolClient {
     }
 
     public String request(HttpRequestBase request) throws IOException {
-
-        HttpEntity entity = null;
-        CloseableHttpResponse response = request((HttpUriRequest) request);
-        if (response == null) {
-            log.error("call api exception no response");
-            throw new RuntimeException("call api exception no response");
-        }
-        entity = response.getEntity();
-        String content = null;
-        if (entity != null) {
-            content = EntityUtils.toString(entity, "UTF-8");
-        }
-        int httpStatus = response.getStatusLine().getStatusCode();
-        if (httpStatus == HttpStatus.SC_OK) {
-            return content;
+        int retry = 0;
+        while (retry <= 3) {
+            try {
+                retry++;
+                HttpEntity entity = null;
+                CloseableHttpResponse response = request((HttpUriRequest) request);
+                if (response == null) {
+                    log.error("call api exception no response");
+                    throw new RuntimeException("call api exception no response");
+                }
+                entity = response.getEntity();
+                String content = null;
+                if (entity != null) {
+                    content = EntityUtils.toString(entity, "UTF-8");
+                }
+                int httpStatus = response.getStatusLine().getStatusCode();
+                if (httpStatus == HttpStatus.SC_OK) {
+                    return content;
+                }
+                String path = request.getURI().toString();
+                log.error("http call api {} fail response status {} content {}", path, httpStatus, content);
+            } catch (Exception e) {
+                log.error("request error", e);
+            }
         }
-        String path = request.getURI().toString();
-        log.error("http call api {} fail response status {} content {}", path, httpStatus, content);
         return null;
     }
 

+ 3 - 0
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -480,6 +480,9 @@ public class WeComHistoryDataJob {
         String cursor = "";
         do {
             String res = getGroupMsgTask(msgId, cursor, corpId);
+            if (StringUtils.isEmpty(res)) {
+                break;
+            }
             JSONObject jsonObject = JSONObject.parseObject(res);
             Integer errCode = jsonObject.getInteger("errcode");
             if (errCode != 0) {