hotfix/improve-batch-operation - 限制同时操作同一个实例数据

This commit is contained in:
wangli 2024-07-01 15:17:36 +08:00
parent e23dd75c3c
commit 018c4bb9eb

View File

@ -18,7 +18,6 @@ import org.springframework.data.redis.core.types.Expiration;
import java.nio.charset.Charset;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* 增加一个拦截器,用来控制多个操作,不允许同时操作同一个实例
@ -27,7 +26,7 @@ import java.util.concurrent.TimeUnit;
* @since 2024/7/1 13:51
*/
public class CustomLockProcessInstanceInterceptor extends AbstractCommandInterceptor {
private String key_prefix = "operation:processInstance:";
private static final String KEY_PREFIX = "operation:processInstance:";
/**
* 解锁脚本原子操作
*/
@ -52,7 +51,7 @@ public class CustomLockProcessInstanceInterceptor extends AbstractCommandInterce
String token = null;
try {
do {
token = getLock(abstractCommand.getProcessInstanceId(), 10 * 1000, 11 * 1000);
token = getLock(KEY_PREFIX + abstractCommand.getProcessInstanceId(), 10 * 1000, 11 * 1000);
} while (Objects.isNull(token));
return next.execute(config, command, commandExecutor);
} finally {