Commit f0f91796 by 墨竹

fix:加好友重试5次

parent 03579d1e
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
......@@ -76,6 +77,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
......@@ -83,6 +85,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private static final Logger log = LogManager.getLogger(MemberUnionidRelatedApiServiceImpl.class);
private static final String SELF_APP = "selfSuiteId";
/**
* 限制次数
*/
private static final Integer MAX_TIMES = 5;
@Autowired
private MemberUnionRelatedService memberUnionRelatedService;
......@@ -1843,9 +1849,16 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
TabHaobanExternalClerkRelated externalClerkRelated = externalClerkRelatedMapper.getByRelationKey(relationKey);
if (externalClerkRelated == null) {
log.error("关注公共号-会员回调好办关联好友,未查询到,relationKey:{}", relationKey);
//重试5次
Integer currentTimes = Convert.toInt(RedisUtil.getCache(relationKey), 0);
if (currentTimes > MAX_TIMES) {
log.error("关注公共号-会员回调好办关联好友重试超过最大次数,relationKey:{}",relationKey);
return;
}
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("addMemberUnionidWechatAccountByClerkMq", res,5);
clientInstance.sendMessage("addMemberUnionidWechatAccountByClerkMq", res, 180);
RedisUtil.setCache(relationKey, currentTimes + 1, 2L, TimeUnit.HOURS);
} catch (Exception e) {
log.info("发送消息异常:{}", e.getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment