【发布时间】:2016-05-25 12:30:36
【问题描述】:
我正在使用 Orion Context Broker 1.1.0 版
我的数据库中只有一个实体:
{
"id"=>"Room1",
"type"=>"Room",
"temperature"=>{"type"=>"none", "value"=>10, "metadata"=>{}}
}
我没有subscription。
然后我创建了 3 个subscriptions:
[
{
"subject"=>{"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"], "expression"=>{"q"=>"temperature>10"}}}
},
{
"subject"=>{"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"], "expression"=>{"q"=>"temperature<10"}}}
},
{
"subject"=>{"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"], "expression"=>{"q"=>"temperature==10"}}}
}
]
如您所见,区别仅在于表达式:temperature>10,temperature,温度==10。
因此,每当我更改 Room1 温度时,我应该只有一个 subscription 触发通知。
但它不能正常工作!!!
每次我更改温度,我都会收到所有 3 个通知。
但是,在创建 subscriptions 时,只有其中一个触发了通知,具体取决于 Room1 的 temperature 值。它按预期工作。
但是当Room1 temperature被更改时,它不能正常工作并触发所有3个通知。
编辑: GET /v2/subscriptions 操作的完整输出:
[
{
"id"=>"574716a22fe8cdc00a696a94",
"expires"=>"2017-04-05T14:00:00.00Z",
"status"=>"active",
"subject"=>{
"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"],
"expression"=>{"q"=>"temperature>10"}}
},
"notification"=>{"attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
"throttling"=>5
},
{
"id"=>"574716a22fe8cdc00a696a95",
"expires"=>"2017-04-05T14:00:00.00Z",
"status"=>"active",
"subject"=>{
"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"],
"expression"=>{"q"=>"temperature<10"}}
},
"notification"=>{"attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
"throttling"=>5},
{
"id"=>"574716a22fe8cdc00a696a96",
"expires"=>"2017-04-05T14:00:00.00Z",
"status"=>"active",
"subject"=>{
"entities"=>[{"id"=>"Room1", "idPattern"=>"", "type"=>""}],
"condition"=>{"attrs"=>["temperature"],
"expression"=>{"q"=>"temperature==10"}}
},
"notification"=>{"timesSent"=>2, "lastNotification"=>"2016-05-26T15:30:42.00Z", "attrs"=>["temperature"], "http"=>{"url"=>"http://localhost:1028/accumulate"}},
"throttling"=>5
}
]
Edit2:添加一些场景:
- 将
Room1 temperature更改为 11 - 具有相同的输出,但
[...{"timesSent"=>1}..., ...{"timesSent"=>1}..., ...{"timesSent"=>3}...] - 将
Room1 temperature更改为 10 - 具有相同的输出,但
[...{"timesSent"=>2}..., ...{"timesSent"=>2}..., ...{"timesSent"=>4}...] - 将
Room1 temperature更改为 9 - 具有相同的输出,但
[...{"timesSent"=>3}..., ...{"timesSent"=>3}..., ...{"timesSent"=>5}...]
【问题讨论】:
-
您能否编辑您的答案以包含
GET /v2/subscriptions操作的输出,好吗?谢谢! -
编辑了答案,添加了 GET /v2/subscriptions 操作的输出,
-
查看结果,注意只有最后一个订阅(
574716a22fe8cdc00a696a96)应该timesSent和lastNotification,即似乎只有最后一个被触发了... -
让我们看看您收到的通知有效负载...您能否编辑您的问题以包含您收到的通知有效负载(由相应的更新触发),好吗?谢谢!
-
我添加了一个场景并输出结果。这就是你想要的吗?
标签: fiware fiware-orion