update - 处理 dev 环境发现的一个 Redisson 版本不兼容的问题
This commit is contained in:
parent
faaf6250db
commit
556b8751e0
@ -84,7 +84,7 @@ public class CustomTaskHelper {
|
||||
throw new WorkflowEngineException(TASK_COMPLETE_FAIL_NOT_EXISTS);
|
||||
}
|
||||
if (Objects.nonNull(originTaskAssigner) &&
|
||||
!Objects.equals(taskEntity.getAssignee(), originTaskAssigner.getAssignee())) {
|
||||
!Objects.equals(taskEntity.getAssignee(), originTaskAssigner.buildAssigneeId())) {
|
||||
throw new WorkflowEngineException(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<artifactId>redisson-spring-data-32</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<artifactId>redisson-spring-data-24</artifactId>
|
||||
<version>${redisson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -60,7 +60,10 @@ public class RepeatSubmitAspect {
|
||||
String paramsKey = SecureUtil.md5(nowParams);
|
||||
// 唯一标识(指定key + url + 消息头)
|
||||
String cacheRepeatKey = REPEAT_SUBMIT_KEY + url + ":" + paramsKey;
|
||||
if (RedisUtils.setObjectIfAbsent(cacheRepeatKey, "", Duration.ofMillis(interval))) {
|
||||
|
||||
String key = RedisUtils.getCacheObject(cacheRepeatKey);
|
||||
if (key == null) {
|
||||
RedisUtils.setCacheObject(cacheRepeatKey, "", Duration.ofMillis(interval));
|
||||
KEY_CACHE.set(cacheRepeatKey);
|
||||
} else {
|
||||
throw new WorkflowEngineException(REPEAT_SUBMIT_ERROR_TIPS, repeatSubmit.message());
|
||||
@ -144,7 +147,8 @@ public class RepeatSubmitAspect {
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
try {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes attributes =
|
||||
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
return attributes.getRequest();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
||||
@ -10,7 +10,6 @@ import org.redisson.api.RBucketAsync;
|
||||
import org.redisson.api.RKeys;
|
||||
import org.redisson.api.RList;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RMapAsync;
|
||||
import org.redisson.api.RRateLimiter;
|
||||
import org.redisson.api.RSet;
|
||||
import org.redisson.api.RTopic;
|
||||
@ -19,6 +18,7 @@ import org.redisson.api.RateType;
|
||||
import org.redisson.api.RedissonClient;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -35,7 +35,6 @@ import java.util.stream.Stream;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
public class RedisUtils {
|
||||
|
||||
private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
|
||||
|
||||
/**
|
||||
@ -137,22 +136,10 @@ public class RedisUtils {
|
||||
RBatch batch = CLIENT.createBatch();
|
||||
RBucketAsync<T> bucket = batch.getBucket(key);
|
||||
bucket.setAsync(value);
|
||||
bucket.expireAsync(duration);
|
||||
bucket.expireAsync(Instant.now().plus(duration));
|
||||
batch.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果不存在则设置 并返回 true 如果存在则返回 false
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @return set成功或失败
|
||||
*/
|
||||
public static <T> boolean setObjectIfAbsent(final String key, final T value, final Duration duration) {
|
||||
RBucket<T> bucket = CLIENT.getBucket(key);
|
||||
return bucket.setIfAbsent(value, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册对象监听器
|
||||
* <p>
|
||||
@ -186,7 +173,7 @@ public class RedisUtils {
|
||||
*/
|
||||
public static boolean expire(final String key, final Duration duration) {
|
||||
RBucket rBucket = CLIENT.getBucket(key);
|
||||
return rBucket.expire(duration);
|
||||
return rBucket.expire(Instant.now().plus(duration));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,21 +385,6 @@ public class RedisUtils {
|
||||
return rMap.remove(hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键
|
||||
*/
|
||||
public static <T> void delMultiCacheMapValue(final String key, final Set<String> hKeys) {
|
||||
RBatch batch = CLIENT.createBatch();
|
||||
RMapAsync<String, T> rMap = batch.getMap(key);
|
||||
for (String hKey : hKeys) {
|
||||
rMap.removeAsync(hKey);
|
||||
}
|
||||
batch.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user