|
@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
|
|
|
import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
|
|
|
import cn.com.qmth.examcloud.web.exception.SequenceLockException;
|
|
|
+import cn.com.qmth.examcloud.web.interceptor.SeqlockInterceptor;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.web.support.ServletUtil;
|
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
@@ -51,7 +52,9 @@ public class SequenceLockHelper {
|
|
|
|
|
|
String key = LOCK_PREFIX + StringUtils.join(Arrays.asList(args), "_");
|
|
|
|
|
|
- if (getRedisClient().setIfAbsent(key, ThreadLocalUtil.getTraceId(), 60 * 5)) {
|
|
|
+ int timeout = 60 * 2;
|
|
|
+
|
|
|
+ if (getRedisClient().setIfAbsent(key, ThreadLocalUtil.getTraceId(), timeout)) {
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("locked");
|
|
|
}
|
|
@@ -65,6 +68,11 @@ public class SequenceLockHelper {
|
|
|
ServletUtil.getRequest().setAttribute(
|
|
|
HttpServletRequestAttribute.$_CUSTOM_SEQUENCE_LOCK.name(), keyList);
|
|
|
} else {
|
|
|
+ Long expire = getRedisClient().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ if (null == expire || expire > timeout) {
|
|
|
+ getRedisClient().delete(key);
|
|
|
+ }
|
|
|
+
|
|
|
throw new SequenceLockException("请求等待,请稍后重试!");
|
|
|
}
|
|
|
}
|