hotfix/improve-batch-operation - 限制同时操作同一个实例数据
This commit is contained in:
parent
e23dd75c3c
commit
018c4bb9eb
@ -18,7 +18,6 @@ import org.springframework.data.redis.core.types.Expiration;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加一个拦截器,用来控制多个操作,不允许同时操作同一个实例
|
* 增加一个拦截器,用来控制多个操作,不允许同时操作同一个实例
|
||||||
@ -27,7 +26,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @since 2024/7/1 13:51
|
* @since 2024/7/1 13:51
|
||||||
*/
|
*/
|
||||||
public class CustomLockProcessInstanceInterceptor extends AbstractCommandInterceptor {
|
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;
|
String token = null;
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
token = getLock(abstractCommand.getProcessInstanceId(), 10 * 1000, 11 * 1000);
|
token = getLock(KEY_PREFIX + abstractCommand.getProcessInstanceId(), 10 * 1000, 11 * 1000);
|
||||||
} while (Objects.isNull(token));
|
} while (Objects.isNull(token));
|
||||||
return next.execute(config, command, commandExecutor);
|
return next.execute(config, command, commandExecutor);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user