diff --git a/application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java b/application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java index 1cda590a1f..04007e949c 100644 --- a/application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java +++ b/application/src/main/java/org/thingsboard/server/service/subscription/TbSubscription.java @@ -21,6 +21,7 @@ import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.TenantId; import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; @Data @@ -35,6 +36,8 @@ public abstract class TbSubscription { private final TbSubscriptionType type; private final BiConsumer, T> updateProcessor; + protected final AtomicInteger sequence = new AtomicInteger(); + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsCountUpdate.java b/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsCountUpdate.java index 93f51a965b..42dc670a21 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsCountUpdate.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsCountUpdate.java @@ -28,14 +28,17 @@ import org.thingsboard.server.service.ws.telemetry.cmd.v2.CmdUpdateType; public class UnreadNotificationsCountUpdate extends CmdUpdate { private final int totalUnreadCount; + private final int sequenceNumber; @Builder @JsonCreator public UnreadNotificationsCountUpdate(@JsonProperty("cmdId") int cmdId, @JsonProperty("errorCode") int errorCode, @JsonProperty("errorMsg") String errorMsg, - @JsonProperty("totalUnreadCount") int totalUnreadCount) { + @JsonProperty("totalUnreadCount") int totalUnreadCount, + @JsonProperty("sequenceNumber") int sequenceNumber) { super(cmdId, errorCode, errorMsg); this.totalUnreadCount = totalUnreadCount; + this.sequenceNumber = sequenceNumber; } @Override diff --git a/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsUpdate.java b/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsUpdate.java index c0de2103ed..bb3ac6e77e 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsUpdate.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/notification/cmd/UnreadNotificationsUpdate.java @@ -33,6 +33,7 @@ public class UnreadNotificationsUpdate extends CmdUpdate { private final List notifications; private final Notification update; private final int totalUnreadCount; + private final int sequenceNumber; @Builder @JsonCreator @@ -40,11 +41,13 @@ public class UnreadNotificationsUpdate extends CmdUpdate { @JsonProperty("errorMsg") String errorMsg, @JsonProperty("notifications") List notifications, @JsonProperty("update") Notification update, - @JsonProperty("totalUnreadCount") int totalUnreadCount) { + @JsonProperty("totalUnreadCount") int totalUnreadCount, + @JsonProperty("sequenceNumber") int sequenceNumber) { super(cmdId, errorCode, errorMsg); this.notifications = notifications; this.update = update; this.totalUnreadCount = totalUnreadCount; + this.sequenceNumber = sequenceNumber; } @Override diff --git a/application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java b/application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java index 5263f9d651..94939682e9 100644 --- a/application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java +++ b/application/src/main/java/org/thingsboard/server/service/ws/notification/sub/NotificationsCountSubscription.java @@ -41,6 +41,7 @@ public class NotificationsCountSubscription extends TbSubscription