我在我的Draco副刊中使用"onlyChangedAttrs“= true,但它似乎不起作用。它仍然在发送所有的属性,不管它是否被修改。这个特性在猎户座的一个特定版本中工作吗?然而,我使用的最新版本的猎户座"2.4.0-next“。你能帮我把这个修好吗。谢谢你的帮忙!我的draco订阅书附在这里:
curl -iX POST 'http://localhost:1026/v2/subscriptions' \
-H 'Content-Type: application/json' \
-H 'fiware-service: tk' \
-H 'fiware-servicepath: /' \
-d '{
"description": "Notify Draco of all context changes",
"subject": {
"entities": [
{
"idPattern": ".*"
}
]
},
"notification": {
"http": {
"url": "http://52.172.34.29:3003/v2/notify"
},
"onlyChangedAttrs":true,
},
"throttling": 0
}'还附加了在修改属性后发送给德拉科的有效载荷(请注意所有发送的属性,尽管我们只修改了名为“Temp”的属性):
{
"subscriptionId":"5eb290700d76dc473d3a5ace",
"data":[
{
"id":"urn:ngsi-ld:SENSOR:Wireless_Sensor-10",
"type":"SENSOR",
"A02":{
"type":"Number",
"value":20,
"metadata":{
}
},
"Description":{
"type":"Text",
"value":"",
"metadata":{
}
},
"Temp":{
"type":"Number",
"value":30,
"metadata":{
}
},
"hasParent":{
"type":"Text",
"value":"urn:ngsi-ld:HVAC:HVAC1",
"metadata":{
}
},
"isPartofContextTree":{
"type":"Text",
"value":"",
"metadata":{
}
},
"name":{
"type":"Text",
"value":"Wireless_Sensor-10",
"metadata":{
}
}
}
]
}Orion的版本详细信息:获取/version
{
"orion" : {
"version" : "2.4.0-next",
"uptime" : "0 d, 0 h, 1 m, 7 s",
"git_hash" : "4f26834ca928e468b091729d93dabd22108a2690",
"compile_time" : "Tue Mar 31 16:21:23 UTC 2020",
"compiled_by" : "root",
"compiled_in" : "3369cff2fa4c",
"release_date" : "Tue Mar 31 16:21:23 UTC 2020",
"doc" : "https://fiware-orion.rtfd.io/"
}
}/v2/订阅的输出:
[
{
"id":"5eb3e7fa331ff6cb547598e1",
"description":"Notify Draco of all context changes",
"status":"active",
"subject":{
"entities":[
{
"idPattern":".*"
}
],
"condition":{
"attrs":[
]
}
},
"notification":{
"attrs":[
],
"attrsFormat":"normalized",
"http":{
"url":"http://52.172.34.29:3003/v2/notify"
},
"onlyChangedAttrs":true
}
}
]下面是mongodb -> orion模式-> csubs集合中的JSON:
{
"_id":"ObjectId(" "5eb3e7fa331ff6cb547598e1" ")",
"expiration":"NumberLong(" "9223372036854775807" ")",
"reference":"http://52.172.34.29:3003/v2/notify",
"custom":false,
"throttling":NumberLong(0),
"servicePath":"/",
"description":"Notify Draco of all context changes",
"status":"active",
"entities":[
{
"id":".*",
"isPattern":"true"
}
],
"attrs":[
],
"metadata":[
],
"blacklist":false,
"onlyChanged":true,
"conditions":[
],
"expression":{
"q":"",
"mq":"",
"geometry":"",
"coords":"",
"georel":""
},
"format":"normalized"
} 发布于 2020-05-14 16:13:05
请注意,在GET /v2/subscriptions和MongoDB ( ID为5eb3e7fa331ff6cb547598e1)中获得的订阅并不是导致通知的相同原因( ID为5eb290700d76dc473d3d3a5ace)。此外,订阅5eb3e7fa331ff6cb547598e1从未被触发(在这种情况下,应该显示发送通知的数量和上次通知的时间戳的计数器)。
因此,我的理论是,另一个订阅(可能在另一个上下文代理中)导致了您的通知,而且订阅可能没有使用onlyChangedAttrs。
编辑:在使用子缓存时,onlyChangedAttrs特性似乎存在问题。一个问题将在Orion代码存储库中创建并最终解决。同时,使用-noCache可以作为解决方案。
EDIT2:Orion存储库中创建的问题:https://github.com/telefonicaid/fiware-orion/issues/3906
EDIT3:这个问题已经在OrionVersion3.2.0中解决了
https://stackoverflow.com/questions/61591877
复制相似问题