错误大概长这样
版本:thingsboard edge 3.4.1
解决:
数据库中的 queue表内少数据 所以导致初始化失败(后面详细说)
将以下转换为sql脚本
INSERT INTO "queue" ("id", "created_time", "tenant_id", "name", "topic", "poll_interval", "partitions", "consumer_per_partition", "pack_processing_timeout", "submit_strategy", "processing_strategy", "additional_info") VALUES ('192c9a80-e274-11ec-af68-f9de2e74cff0', 1654174880808, '13814000-1dd2-11b2-8080-808080808080', 'Main', 'tb_rule_engine.main', 25, 24, 't', 2000, '{"type":"BURST","batchSize":1000}', '{"type":"SKIP_ALL_FAILURES","retries":1,"failurePercentage":0.0,"pauseBetweenRetries":0,"maxPauseBetweenRetries":3}', NULL);
INSERT INTO "queue" ("id", "created_time", "tenant_id", "name", "topic", "poll_interval", "partitions", "consumer_per_partition", "pack_processing_timeout", "submit_strategy", "processing_strategy", "additional_info") VALUES ('1958daa0-e274-11ec-af68-f9de2e74cff0', 1654174881098, '13814000-1dd2-11b2-8080-808080808080', 'HighPriority', 'tb_rule_engine.hp', 25, 24, 't', 2000, '{"type":"BURST","batchSize":100}', '{"type":"RETRY_FAILED_AND_TIMED_OUT","retries":0,"failurePercentage":0.0,"pauseBetweenRetries":5,"maxPauseBetweenRetries":5}', NULL);
INSERT INTO "queue" ("id", "created_time", "tenant_id", "name", "topic", "poll_interval", "partitions", "consumer_per_partition", "pack_processing_timeout", "submit_strategy", "processing_strategy", "additional_info") VALUES ('195b2490-e274-11ec-af68-f9de2e74cff0', 1654174881113, '13814000-1dd2-11b2-8080-808080808080', 'SequentialByOriginator', 'tb_rule_engine.sq', 25, 24, 't', 2000, '{"type":"SEQUENTIAL_BY_ORIGINATOR","batchSize":100}', '{"type":"RETRY_FAILED_AND_TIMED_OUT","retries":3,"failurePercentage":0.0,"pauseBetweenRetries":5,"maxPauseBetweenRetries":5}', NULL);
然后再数据库中导入解决。
原因:
报错位置在这里
partitionSizesMap 中仅有两条数据 关于 rule-engine的数据都没有 导致出现去寻找rule-engine的内容时 partitionSize为空 之后202行便出现空指针异常。
往里顺藤摸瓜:
中间还有的过程自己跑一下呗 就是一层层往里找
然后就发现肯定是数据库表中少数据了
然后阴间手段拿到数据 填进去解决!
提一嘴 有些版本的thingsboard给edge的规则链是有问题的 这边提供一个 不用谢
一下是json文件
{
"ruleChain": {
"additionalInfo": null,
"name": "Edge Root Rule Chain",
"type": "EDGE",
"firstRuleNodeId": null,
"root": false,
"debugMode": false,
"configuration": null
},
"metadata": {
"firstNodeIndex": 0,
"nodes": [
{
"additionalInfo": {
"description": "Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \"Success\" relation type.",
"layoutX": 187,
"layoutY": 468
},
"type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode",
"name": "Device Profile Node",
"debugMode": false,
"configuration": {
"persistAlarmRulesState": false,
"fetchAlarmRulesStateOnStart": false
}
},
{
"additionalInfo": {
"layoutX": 820,
"layoutY": 289
},
"type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode",
"name": "Save Timeseries",
"debugMode": false,
"configuration": {
"defaultTTL": 0
}
},
{
"additionalInfo": {
"layoutX": 594,
"layoutY": 34
},
"type": "org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode",
"name": "Save Client Attributes",
"debugMode": false,
"configuration": {
"scope": "CLIENT_SCOPE"
}
},
{
"additionalInfo": {
"layoutX": 347,
"layoutY": 149
},
"type": "org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode",
"name": "Message Type Switch",
"debugMode": false,
"configuration": {
"version": 0
}
},
{
"additionalInfo": {
"layoutX": 809,
"layoutY": 410
},
"type": "org.thingsboard.rule.engine.action.TbLogNode",
"name": "Log RPC from Device",
"debugMode": false,
"configuration": {
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
}
},
{
"additionalInfo": {
"layoutX": 776,
"layoutY": 512
},
"type": "org.thingsboard.rule.engine.action.TbLogNode",
"name": "Log Other",
"debugMode": false,
"configuration": {
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
}
},
{
"additionalInfo": {
"layoutX": 434,
"layoutY": 538
},
"type": "org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode",
"name": "RPC Call Request",
"debugMode": false,
"configuration": {
"timeoutInSeconds": 60
}
},
{
"additionalInfo": {
"layoutX": 1204,
"layoutY": 183
},
"type": "org.thingsboard.rule.engine.edge.TbMsgPushToCloudNode",
"name": "Push to cloud",
"debugMode": false,
"configuration": {
"scope": "SERVER_SCOPE"
}
}
],
"connections": [
{
"fromIndex": 0,
"toIndex": 3,
"type": "Success"
},
{
"fromIndex": 1,
"toIndex": 7,
"type": "Success"
},
{
"fromIndex": 2,
"toIndex": 7,
"type": "Success"
},
{
"fromIndex": 3,
"toIndex": 1,
"type": "Post telemetry"
},
{
"fromIndex": 3,
"toIndex": 2,
"type": "Post attributes"
},
{
"fromIndex": 3,
"toIndex": 4,
"type": "RPC Request from Device"
},
{
"fromIndex": 3,
"toIndex": 5,
"type": "Other"
},
{
"fromIndex": 3,
"toIndex": 6,
"type": "RPC Request to Device"
},
{
"fromIndex": 3,
"toIndex": 7,
"type": "Attributes Deleted"
},
{
"fromIndex": 3,
"toIndex": 7,
"type": "Attributes Updated"
},
{
"fromIndex": 3,
"toIndex": 7,
"type": "Timeseries Deleted"
},
{
"fromIndex": 3,
"toIndex": 7,
"type": "Timeseries Updated"
},
{
"fromIndex": 4,
"toIndex": 7,
"type": "Success"
}
],
"ruleChainConnections": null
}
}