rev:redisson自动续期问题

This commit is contained in:
2024-01-27 16:25:26 +08:00
parent 5768cf1d30
commit 7b880b48bc

View File

@@ -201,7 +201,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String type = whereJson.getString("type");
JSONObject result = new JSONObject();
RLock lock = redissonClient.getLock("acs_to_wms:" + type);
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS);
boolean tryLock = lock.tryLock(5,20, TimeUnit.SECONDS);
try {
if (tryLock) {
String device_code = whereJson.getString("device_code");
@@ -625,8 +625,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result;
}
} finally {
if (tryLock) {
lock.unlock();
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
try {
lock.unlock();
}catch (Exception ex){}
}
}
result.put("status", HttpStatus.BAD_REQUEST.value());