Commit 445c18e6 by huangfusuper

分布式锁

parent 500723e1
...@@ -14,7 +14,7 @@ import java.util.List; ...@@ -14,7 +14,7 @@ import java.util.List;
public class RedissonProperties { public class RedissonProperties {
private int timeout = 60000; private int timeout = 3000;
private String address; private String address;
......
...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component; ...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
/** /**
* 使用redis分布式锁 * 使用redis分布式锁
...@@ -41,7 +42,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH ...@@ -41,7 +42,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH
Long sleepTime = 0L; Long sleepTime = 0L;
try{ try{
//加锁 60秒后超时 //加锁 60秒后超时
boolean trlock = RedissLockUtil.trlock(lockName, 60); boolean trlock = RedissLockUtil.trlock(lockName, TimeUnit.SECONDS, 1);
if (trlock) { if (trlock) {
log.debug("------------{},加锁成功,锁名称为{}----------",threadName,lockName); log.debug("------------{},加锁成功,锁名称为{}----------",threadName,lockName);
dateAligned(CYCLE_INTERVAL,threadName); dateAligned(CYCLE_INTERVAL,threadName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment