diff --git a/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java b/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java index edb2d7b7fa8..0af50ff8596 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/DefaultWebSocketService.java @@ -260,7 +260,8 @@ private void handleWsAlarmCountCmd(WebSocketSessionRef sessionRef, AlarmCountCmd @Override public void sendUpdate(String sessionId, int cmdId, TelemetrySubscriptionUpdate update) { - doSendUpdate(sessionId, cmdId, update); + // We substitute the subscriptionId with cmdId for old-style subscriptions. + doSendUpdate(sessionId, cmdId, update.copyWithNewSubscriptionId(cmdId)); } @Override diff --git a/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java b/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java index 1320a055cd4..aa1a44096d4 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/telemetry/sub/TelemetrySubscriptionUpdate.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.service.ws.telemetry.sub; +import lombok.AllArgsConstructor; import org.thingsboard.server.common.data.kv.TsKvEntry; import org.thingsboard.server.service.subscription.SubscriptionErrorCode; @@ -26,8 +27,8 @@ import java.util.TreeMap; import java.util.stream.Collectors; +@AllArgsConstructor public class TelemetrySubscriptionUpdate { - private final int subscriptionId; private int errorCode; private String errorMsg; @@ -93,6 +94,10 @@ public String getErrorMsg() { return errorMsg; } + public TelemetrySubscriptionUpdate copyWithNewSubscriptionId(int subscriptionId){ + return new TelemetrySubscriptionUpdate(subscriptionId, errorCode, errorMsg, data); + } + @Override public String toString() { StringBuilder result = new StringBuilder("TelemetrySubscriptionUpdate [subscriptionId=" + subscriptionId + ", errorCode=" + errorCode + ", errorMsg=" + errorMsg + ", data="); diff --git a/dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java index dbd2cb596b6..7ae9837009d 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java @@ -26,6 +26,7 @@ import org.hibernate.exception.ConstraintViolationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.event.TransactionalEventListener; @@ -106,6 +107,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService