Prechádzať zdrojové kódy

腾讯云视频接口请求限制bugfix

wangliang 3 rokov pred
rodič
commit
b47b22ee6e

+ 31 - 29
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -308,39 +308,41 @@ public class MqLogicServiceImpl implements MqLogicService {
 
         Map<String, Object> resultMap = null;
         boolean lockStreamIds = false;
-        for (int i = 0; i < SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT; i++) {
-            lockStreamIds = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString(),
-                    SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_TIME_OUT);
-            if (lockStreamIds) {
-                try {
-                    resultMap = tencentYunUtil.tencentVodSdk(tencentYunUtil.getTencentYunDomain().getSecretId(),
-                            tencentYunUtil.getTencentYunDomain().getSecretKey(),
-                            tencentYunUtil.getTencentYunDomain().getQueryUrl(),
-                            tencentYunUtil.getTencentYunDomain().getVodAppId(),
-                            streamIds);
-                    break;
-                } catch (Exception e) {
-                    log.error("请求出错", e);
-                    if (i == SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT - 1) {
-                        tgErrorService.saveExamTgError(recordId, "execMqTencentVideoLogic");
-                    } else {
-                        try {
-                            Thread.sleep(3000);
-                        } catch (InterruptedException ex) {
-                            ex.printStackTrace();
+        try {
+            for (int i = 0; i < SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT; i++) {
+                lockStreamIds = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString(),
+                        SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_TIME_OUT);
+                if (lockStreamIds) {
+                    try {
+                        resultMap = tencentYunUtil.tencentVodSdk(tencentYunUtil.getTencentYunDomain().getSecretId(),
+                                tencentYunUtil.getTencentYunDomain().getSecretKey(),
+                                tencentYunUtil.getTencentYunDomain().getQueryUrl(),
+                                tencentYunUtil.getTencentYunDomain().getVodAppId(),
+                                streamIds);
+                        break;
+                    } catch (Exception e) {
+                        log.error("请求出错", e);
+                        if (i == SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT - 1) {
+                            tgErrorService.saveExamTgError(recordId, "execMqTencentVideoLogic");
+                        } else {
+                            try {
+                                Thread.sleep(3000);
+                            } catch (InterruptedException ex) {
+                                ex.printStackTrace();
+                            }
                         }
                     }
-                } finally {
-                    if (Objects.nonNull(streamIds)) {
-                        redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString());
+                } else {
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
                     }
                 }
-            } else {
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
+            }
+        } finally {
+            if (Objects.nonNull(streamIds)) {
+                redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString());
             }
         }