diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNode.java index b810774832..27b6acca2e 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNode.java @@ -15,6 +15,7 @@ */ package org.thingsboard.rule.engine.telemetry; +import com.google.common.util.concurrent.FutureCallback; import com.google.gson.JsonParser; import lombok.extern.slf4j.Slf4j; import org.thingsboard.server.common.data.StringUtils; @@ -65,11 +66,15 @@ public class TbMsgAttributesNode implements TbNode { return; } String src = msg.getData(); - List attributes = new ArrayList<>(JsonConverter.convertToAttributes(new JsonParser().parse(src))); + List attributes = new ArrayList<>(JsonConverter.convertToAttributes(JsonParser.parseString(src))); if (attributes.isEmpty()) { ctx.tellSuccess(msg); return; } + FutureCallback callback = new TelemetryNodeCallback(ctx, msg); + if (config.isSendAttributesUpdatedNotification()) { + callback = new AttributesUpdateNodeCallback(ctx, msg, config.getScope(), attributes); + } String notifyDeviceStr = msg.getMetaData().getValue("notifyDevice"); ctx.getTelemetryService().saveAndNotify( ctx.getTenantId(), @@ -77,7 +82,7 @@ public class TbMsgAttributesNode implements TbNode { config.getScope(), attributes, config.getNotifyDevice() || StringUtils.isEmpty(notifyDeviceStr) || Boolean.parseBoolean(notifyDeviceStr), - new AttributesUpdateNodeCallback(ctx, msg, config.getScope(), attributes) + callback ); } diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNodeConfiguration.java index 1586048b81..93b8d63b47 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNodeConfiguration.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgAttributesNodeConfiguration.java @@ -25,12 +25,14 @@ public class TbMsgAttributesNodeConfiguration implements NodeConfiguration keys; + private boolean sendAttributesDeletedNotification; @Override public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { this.config = TbNodeUtils.convert(configuration, TbMsgDeleteAttributesConfiguration.class); this.scope = config.getScope(); this.keys = config.getKeys(); + this.sendAttributesDeletedNotification = config.isSendAttributesDeletedNotification(); } @Override @@ -67,7 +70,11 @@ public class TbMsgDeleteAttributes implements TbNode { if (keysToDelete.isEmpty()) { ctx.tellSuccess(msg); } else { - ctx.getTelemetryService().deleteAndNotify(ctx.getTenantId(), msg.getOriginator(), scope, keysToDelete, new AttributesDeleteNodeCallback(ctx, msg, scope, keysToDelete)); + FutureCallback callback = new TelemetryNodeCallback(ctx, msg); + if (sendAttributesDeletedNotification) { + callback = new AttributesDeleteNodeCallback(ctx, msg, scope, keysToDelete); + } + ctx.getTelemetryService().deleteAndNotify(ctx.getTenantId(), msg.getOriginator(), scope, keysToDelete, callback); } } } diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesConfiguration.java index 03bef2a4e6..a33bcda3f2 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesConfiguration.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/telemetry/TbMsgDeleteAttributesConfiguration.java @@ -27,12 +27,14 @@ public class TbMsgDeleteAttributesConfiguration implements NodeConfiguration keys; + private boolean sendAttributesDeletedNotification; @Override public TbMsgDeleteAttributesConfiguration defaultConfiguration() { TbMsgDeleteAttributesConfiguration configuration = new TbMsgDeleteAttributesConfiguration(); configuration.setScope(DataConstants.SERVER_SCOPE); configuration.setKeys(Collections.emptyList()); + configuration.setSendAttributesDeletedNotification(false); return configuration; } }