Browse Source

updated comment, fixed ctx data changing

pull/13013/head
dashevchenko 2 years ago
parent
commit
f6ad9fed48
  1. 9
      application/src/main/java/org/thingsboard/server/service/subscription/DefaultTbEntityDataSubscriptionService.java

9
application/src/main/java/org/thingsboard/server/service/subscription/DefaultTbEntityDataSubscriptionService.java

@ -725,11 +725,12 @@ public class DefaultTbEntityDataSubscriptionService implements TbEntityDataSubsc
update = new EntityDataUpdate(ctx.getCmdId(), ctx.getData(), null, ctx.getMaxEntitiesPerDataSubscription()); update = new EntityDataUpdate(ctx.getCmdId(), ctx.getData(), null, ctx.getMaxEntitiesPerDataSubscription());
ctx.setInitialDataSent(true); ctx.setInitialDataSent(true);
} else { } else {
// to avoid updating timeseries with empty values // if ctx has timeseries subscription, timeseries values are cleared after each update and is empty in ctx data,
List<EntityData> data = ctx.getData().getData().stream() // so to avoid sending timeseries update with empty map we set it to null
.peek(entityData -> entityData.setTimeseries(null)) List<EntityData> preparedData = ctx.getData().getData().stream()
.map(entityData -> new EntityData(entityData.getEntityId(), entityData.getLatest(), null))
.toList(); .toList();
update = new EntityDataUpdate(ctx.getCmdId(), null, data, ctx.getMaxEntitiesPerDataSubscription()); update = new EntityDataUpdate(ctx.getCmdId(), null, preparedData, ctx.getMaxEntitiesPerDataSubscription());
} }
ctx.sendWsMsg(update); ctx.sendWsMsg(update);
} finally { } finally {

Loading…
Cancel
Save