Search in sources :

Example 1 with TbRuleNodeUpdateException

use of org.thingsboard.server.actors.TbRuleNodeUpdateException in project thingsboard by thingsboard.

the class RuleNodeActorMessageProcessor method onUpdate.

@Override
public void onUpdate(TbActorCtx context) throws Exception {
    RuleNode newRuleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
    this.info = new RuleNodeInfo(entityId, ruleChainName, newRuleNode != null ? newRuleNode.getName() : "Unknown");
    boolean restartRequired = state != ComponentLifecycleState.ACTIVE || !(ruleNode.getType().equals(newRuleNode.getType()) && ruleNode.getConfiguration().equals(newRuleNode.getConfiguration()));
    this.ruleNode = newRuleNode;
    this.defaultCtx.updateSelf(newRuleNode);
    if (restartRequired) {
        if (tbNode != null) {
            tbNode.destroy();
        }
        try {
            start(context);
        } catch (Exception e) {
            throw new TbRuleNodeUpdateException("Failed to update rule node", e);
        }
    }
}
Also used : RuleNodeInfo(org.thingsboard.server.common.msg.queue.RuleNodeInfo) RuleNode(org.thingsboard.server.common.data.rule.RuleNode) TbRuleNodeUpdateException(org.thingsboard.server.actors.TbRuleNodeUpdateException) TbRuleNodeUpdateException(org.thingsboard.server.actors.TbRuleNodeUpdateException) RuleNodeException(org.thingsboard.server.common.msg.queue.RuleNodeException)

Aggregations

TbRuleNodeUpdateException (org.thingsboard.server.actors.TbRuleNodeUpdateException)1 RuleNode (org.thingsboard.server.common.data.rule.RuleNode)1 RuleNodeException (org.thingsboard.server.common.msg.queue.RuleNodeException)1 RuleNodeInfo (org.thingsboard.server.common.msg.queue.RuleNodeInfo)1