|
|
|
@ -19,10 +19,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
|
import com.google.protobuf.ByteString; |
|
|
|
import com.google.protobuf.InvalidProtocolBufferException; |
|
|
|
import lombok.AccessLevel; |
|
|
|
import lombok.Builder; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.id.CustomerId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityIdFactory; |
|
|
|
@ -67,8 +67,7 @@ public final class TbMsg implements Serializable { |
|
|
|
transient private final TbMsgCallback callback; |
|
|
|
|
|
|
|
public static TbMsg newMsg(String queueName, String type, EntityId originator, TbMsgMetaData metaData, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) { |
|
|
|
return new TbMsg(queueName, UUID.randomUUID(), System.currentTimeMillis(), type, originator, null, |
|
|
|
metaData.copy(), TbMsgDataType.JSON, data, ruleChainId, ruleNodeId, 0, TbMsgCallback.EMPTY); |
|
|
|
return newMsg(queueName, type, originator, null, metaData, data, ruleChainId, ruleNodeId); |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String queueName, String type, EntityId originator, CustomerId customerId, TbMsgMetaData metaData, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) { |
|
|
|
@ -77,13 +76,21 @@ public final class TbMsg implements Serializable { |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data) { |
|
|
|
return new TbMsg(ServiceQueue.MAIN, UUID.randomUUID(), System.currentTimeMillis(), type, originator, null, metaData.copy(), TbMsgDataType.JSON, data, null, null, 0, TbMsgCallback.EMPTY); |
|
|
|
return newMsg(type, originator, null, metaData, data); |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String type, EntityId originator, CustomerId customerId, TbMsgMetaData metaData, String data) { |
|
|
|
return new TbMsg(ServiceQueue.MAIN, UUID.randomUUID(), System.currentTimeMillis(), type, originator, customerId, metaData.copy(), TbMsgDataType.JSON, data, null, null, 0, TbMsgCallback.EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
// REALLY NEW MSG
|
|
|
|
|
|
|
|
public static TbMsg newMsg(String queueName, String type, EntityId originator, TbMsgMetaData metaData, String data) { |
|
|
|
return new TbMsg(queueName, UUID.randomUUID(), System.currentTimeMillis(), type, originator, null, metaData.copy(), TbMsgDataType.JSON, data, null, null, 0, TbMsgCallback.EMPTY); |
|
|
|
return newMsg(queueName, type, originator, null, metaData, data); |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String queueName, String type, EntityId originator, CustomerId customerId, TbMsgMetaData metaData, String data) { |
|
|
|
return new TbMsg(queueName, UUID.randomUUID(), System.currentTimeMillis(), type, originator, customerId, metaData.copy(), TbMsgDataType.JSON, data, null, null, 0, TbMsgCallback.EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String type, EntityId originator, CustomerId customerId, TbMsgMetaData metaData, TbMsgDataType dataType, String data) { |
|
|
|
@ -91,7 +98,7 @@ public final class TbMsg implements Serializable { |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data) { |
|
|
|
return new TbMsg(ServiceQueue.MAIN, UUID.randomUUID(), System.currentTimeMillis(), type, originator, null, metaData.copy(), dataType, data, null, null, 0, TbMsgCallback.EMPTY); |
|
|
|
return newMsg(type, originator, null, metaData, dataType, data); |
|
|
|
} |
|
|
|
|
|
|
|
// For Tests only
|
|
|
|
@ -145,7 +152,15 @@ public final class TbMsg implements Serializable { |
|
|
|
} |
|
|
|
this.type = type; |
|
|
|
this.originator = originator; |
|
|
|
this.customerId = (customerId == null || customerId.isNullUid()) ? null : customerId; |
|
|
|
if (customerId == null || customerId.isNullUid()) { |
|
|
|
if (originator.getEntityType() == EntityType.CUSTOMER) { |
|
|
|
this.customerId = (CustomerId) originator; |
|
|
|
} else { |
|
|
|
this.customerId = null; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.customerId = customerId; |
|
|
|
} |
|
|
|
this.metaData = metaData; |
|
|
|
this.dataType = dataType; |
|
|
|
this.data = data; |
|
|
|
|