...
|
...
|
@@ -255,6 +255,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
public UnionResponse activateUnion(ActivateUnionRequestBO request) throws ServiceException {
|
|
|
String ut = null;
|
|
|
String k = null;
|
|
|
boolean getLock = false;
|
|
|
try {
|
|
|
activeUnion.info("activateUnion with request is {}", request);
|
|
|
// 检查输入参数
|
...
|
...
|
@@ -408,7 +409,8 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
|
|
|
ut = click.getUnion_type();
|
|
|
k = key;
|
|
|
if (!getDistributeLock(ut, k)) {
|
|
|
getLock = getDistributeLock(ut, k);
|
|
|
if (!getLock) {
|
|
|
log.info("getDistributeLock failed key is {}", key);
|
|
|
return new UnionResponse(200, "getDistributeLock failed", new JSONObject());
|
|
|
}
|
...
|
...
|
@@ -682,7 +684,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
log.error("activateUnion error with request={}", request, e);
|
|
|
return new UnionResponse(200, e.getMessage(),new JSONObject());
|
|
|
} finally {
|
|
|
deleteDistributeLock(ut, k);
|
|
|
if (getLock) {
|
|
|
deleteDistributeLock(ut, k);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -1466,7 +1470,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
private boolean getDistributeLock(String unionType, String deviceType) {
|
|
|
String key = UNION_KEY + "NX:" + unionType + ":" + deviceType;
|
|
|
try {
|
|
|
yhValueOperations.setIfAbsent(key, "lock");
|
|
|
boolean lock = yhValueOperations.setIfAbsent(key, "lock");
|
|
|
if (!lock) {
|
|
|
return false;
|
|
|
}
|
|
|
redisTemplate.longExpire(key, 30, TimeUnit.SECONDS);
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
...
|
...
|
|