分布式架构
1、分布式锁
String lockkey = "test-info-uid-" + testInfo.getUid();
Lock lock = domainDistributedLockService.obtain(lockkey);
boolean lockFlag = lock.tryLock();
if (!lockFlag) {
log.warn("未获取到锁 ,taskId=" + taskId);
return;
}
try {
} catch (Exception ex) {
throw ex;
} finally {
if (lockFlag) {
lock.unlock();
}
}
@Service
public class RedisDistributedLock implements DomainDistributedLockService {
@Autowired
RedisLockRegistry redisLockRegistry;
@Override
public Lock obtain(String lockKey) {
return redisLockRegistry.obtain(lockKey);
}
}
2、基于状态更新保证幂等
update(int statusBefore, int statusAfter)
3、事前,事中,事后思想
doBefore
do
doAfter
4、

浙公网安备 33010602011771号