redisson
redisson copied to clipboard
tryLock 锁不住
这个我的配置
@Bean public RedissonClient singleRedissonLock () throws URISyntaxException { Config config = new Config(); config.useSingleServer() .setAddress("redis://" + ip + ":" + port) .setConnectTimeout(500) .setPassword(StringUtils.defaultIfEmpty(password, null)); return Redisson.create(config); }
获取锁
`@Resource private RedissonClient redisson;
@Override
public WorPtLock lockWaitAMoment(int workOrderId, String itemId, String tenantId, Long millisecond) {
if (millisecond == null || millisecond <= 0) {
millisecond = A_MOMENT;
}
WorPtLock worPtLock = new WorPtLock(workOrderId, itemId, tenantId);
try {
RLock lock = redisson.getLock(worPtLock.buildLockKey());
boolean b = lock.tryLock(millisecond, TimeUnit.MILLISECONDS);
if (b) {
worPtLock.setLock(lock);
worPtLock.setSuccess(true);
logger.error("加锁中=====threadname:【{}】。。。。。key【{}】---{}", Thread.currentThread().getName(), worPtLock.buildLockKey(), i);
} else {
logger.error("加锁失败=====threadname:【{}】。。。。。key【{}】---{}", Thread.currentThread().getName(), worPtLock.buildLockKey(), i);
worPtLock.setSuccess(false);
}
} catch (Exception e) {
logger.error("获取锁失败,生产单id:{},itemID:{}", workOrderId, itemId);
worPtLock.setSuccess(false);
}
return worPtLock;
}`

请按照模板提供以下运行环境和版本信息,另外能把代码发全吗?
没有设置看门狗时间
没有设置看门狗时间
设置看门狗是什么意思