TanJingyu 1 سال پیش
والد
کامیت
c287fdc3f0
1فایلهای تغییر یافته به همراه12 افزوده شده و 13 حذف شده
  1. 12 13
      src/main/java/com/cybertogether/wx/notice/web/WxPushReceptionController.java

+ 12 - 13
src/main/java/com/cybertogether/wx/notice/web/WxPushReceptionController.java

@@ -2,11 +2,13 @@ package com.cybertogether.wx.notice.web;
 
 import com.cybertogether.wx.notice.infrastructure.Downstream;
 import com.cybertogether.wx.notice.infrastructure.HttpClientUtils;
+import com.cybertogether.wx.notice.infrastructure.HttpResponseContent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Objects;
 
 
 /**
@@ -34,15 +36,14 @@ public class WxPushReceptionController {
                                               @RequestBody String encryptedXmlBodyText) {
         LOGGER.info("微信通知转发服务-收到微信授权通知");
         String urlParams = String.format("?timestamp=%s&nonce=%s&msg_signature=%s", timestamp, nonce, msgSignature);
-
         for (String url : downstream.getUrls()) {
-            try {
-                HttpClientUtils.postData(url + urlParams, encryptedXmlBodyText);
-            }catch (Exception e) {
-                // ignore
+            for (int i = 0; i < 5; i++) {
+                HttpResponseContent hrc = HttpClientUtils.postData(url + urlParams, encryptedXmlBodyText);
+                if (Objects.nonNull(hrc) && hrc.isSuccessful()) {
+                    break;
+                }
             }
         }
-
         return "success";
     }
 
@@ -57,17 +58,15 @@ public class WxPushReceptionController {
                                     @RequestBody String encryptedXmlBodyText,
                                     @PathVariable String appId) {
         LOGGER.info("微信通知转发服务-收到微信消息与事件通知");
-
         String urlParams = String.format("?timestamp=%s&nonce=%s&msg_signature=%s", timestamp, nonce, msgSignature);
-
         for (String url : downstream.getMsgUrls()) {
-            try {
-                HttpClientUtils.postData(url + appId + urlParams, encryptedXmlBodyText);
-            }catch (Exception e) {
-                // ignore
+            for (int i = 0; i < 5; i++) {
+                HttpResponseContent hrc = HttpClientUtils.postData(url + appId + urlParams, encryptedXmlBodyText);
+                if (Objects.nonNull(hrc) && hrc.isSuccessful()) {
+                    break;
+                }
             }
         }
-
         return "success";
     }
 }