Commit 83876013 by fanjiaxin

联调问题处理

parent b126101a
Pipeline #71590 passed with stages
in 1 minute 2 seconds
......@@ -29,6 +29,14 @@ public interface CoreConstant {
* Redis微信认证Token锁
*/
String REDIS_TOKEN_WECHAT_LOCK_KEY = "TOKEN:WECHAT:LOCK";
/**
* Redis微信认证Token锁时间,秒
*/
String REDIS_TOKEN_WECHAT_LOCK_VALUE = "wechat:lock";
/**
* Redis微信认证Token锁时间,秒
*/
int REDIS_TOKEN_WECHAT_LOCK_TIME = 10;
/**
* Redis微信小店认证Token
......@@ -38,4 +46,12 @@ public interface CoreConstant {
* Redis微信小店认证Token锁
*/
String REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY = "TOKEN:WECHAT:SHOP:LOCK";
/**
* Redis微信小店认证Token锁时间,秒
*/
String REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE = "wechat:shop:lock";
/**
* Redis微信小店认证Token锁时间,秒
*/
int REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME = 10;
}
......@@ -25,7 +25,7 @@ public class WeChatContextHolder {
private final WeChatShopAccessTokenRequest weChatShopAccessTokenRequest;
private static final long RETRY_DELAY_MS = 200;
private static final int EXPIRE_SECONDS = 5 * 60;
private static final int EXPIRE_SECONDS = 30 * 60;
/**
* 获取微信认证信息
......@@ -48,7 +48,8 @@ public class WeChatContextHolder {
*/
public String createAccessToken() throws InterruptedException {
// 设置10秒的锁
boolean locked = redisClient.setIfAbsent(CoreConstant.REDIS_TOKEN_WECHAT_LOCK_KEY, "locked", 10);
boolean locked = redisClient.setIfAbsent(CoreConstant.REDIS_TOKEN_WECHAT_LOCK_KEY,
CoreConstant.REDIS_TOKEN_WECHAT_LOCK_VALUE, CoreConstant.REDIS_TOKEN_WECHAT_LOCK_TIME);
if (!locked) {
// 未获取到锁,等待一段时间后重试
TimeUnit.MILLISECONDS.sleep(RETRY_DELAY_MS);
......@@ -81,7 +82,8 @@ public class WeChatContextHolder {
*/
public String createShopAccessToken() throws InterruptedException {
// 设置10秒的锁
boolean locked = redisClient.setIfAbsent(CoreConstant.REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY, "locked", 10);
boolean locked = redisClient.setIfAbsent(CoreConstant.REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY,
CoreConstant.REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE, CoreConstant.REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME);
if (!locked) {
// 未获取到锁,等待一段时间后重试
TimeUnit.MILLISECONDS.sleep(RETRY_DELAY_MS);
......
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