123バックアップ

2562 ワード



        String alock = deviceStatusSyncParam.getSn();
        APIResult res = new APIResult();
        RLock lock = redissonClient.getLock(alock);
        boolean getLock = false;
        try {
            if (getLock = lock.tryLock(120, TimeUnit.SECONDS)) {
                logger.info("start time:" + DateUtils.format(new Date()));
                logger.info("Redisson :{},ThreadName:{}", alock, Thread.currentThread().getName());

                String redisCompanyCode = Optional.ofNullable(stringRedisTemplate.opsForHash().get(RedisKey.getDeviceInfo(deviceStatusSyncParam.getSn()), RedisKey.DeviceField.companyCode.name()))
                        .map(Object::toString).orElse(StringUtils.EMPTY);
                logger.info("[companyCode] io :" + deviceStatusSyncParam.getCompanyCode());
                logger.info("[redisCompanyCode] redis :" + deviceStatusSyncParam.getCompanyCode());
                logger.info("[syncStatus] io :" + syncStatus);
                if (!(!deviceStatusSyncParam.getCompanyCode().equals(redisCompanyCode) && syncStatus.equals(-1))) {
                    logger.info(" device ");
                    this.cache(Collections.singletonList(device), CurdEnum.UPDATE, deviceStatusSyncParam.getCompanyCode());
                }
                Thread.sleep(60000);
                System.out.println("sleeping ...  ");
                logger.info("end time:" + DateUtils.format(new Date()));
            } else {
                logger.info("Redisson :{},ThreadName:{}", alock, Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            logger.error("Redisson ", e);
        } finally {
            if (!getLock) {
                return;
            }
            lock.unlock();
            logger.info("Redisson ");
        }
    }



            org.redisson
            redisson-spring-boot-starter
            3.10.7
            
                
                    org.redisson
                    redisson-spring-data-21
                
            
        
        
            org.redisson
            redisson-spring-data-20
            3.10.7