Commit e1cb13d5 authored by 赵啸非's avatar 赵啸非

修改设备更新线程实现逻辑

parent 48376da6
......@@ -33,21 +33,23 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
@Override
protected int getSleepTime() {
return 500;
return 1000;
}
@Override
protected void process() {
protected void process() {
log.info("DeviceUpdateComsumerThread process");
List<DeviceEntity> waitUpdateDeviceList = new ArrayList<>();
DeviceEntity deviceEntity = cacheService.lpop(RedisKey.KEY_DEVICE_UPDATE_QUEUE, DeviceEntity.class);
if (!ObjectUtils.isEmpty(deviceEntity)) {
// log.info("deviceEntity:{}", deviceEntity == null);
waitUpdateDeviceList.add(deviceEntity);
while (true) {
DeviceEntity deviceEntity = cacheService.blpop(RedisKey.KEY_DEVICE_UPDATE_QUEUE, 10,DeviceEntity.class);
if (ObjectUtils.isEmpty(deviceEntity)) {
log.info("deviceEntity:{}", deviceEntity == null);
break;
} else {
waitUpdateDeviceList.add(deviceEntity);
}
}
if (!ObjectUtils.isEmpty(waitUpdateDeviceList)) {
log.info("updateDeviceList size:{}", waitUpdateDeviceList.size());
deviceService.update(waitUpdateDeviceList);
......
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