【问题标题】:Fiware Orion context broker subscriptions condition does not workFiware Orion 上下文代理订阅条件不起作用
【发布时间】: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:添加一些场景:

  1. 将 Room1 temperature 更改为 11
  2. 具有相同的输出,但 [...{"timesSent"=&gt;1}..., ...{"timesSent"=&gt;1}..., ...{"timesSent"=&gt;3}...]
  3. 将 Room1 temperature 更改为 10
  4. 具有相同的输出,但 [...{"timesSent"=&gt;2}..., ...{"timesSent"=&gt;2}..., ...{"timesSent"=&gt;4}...]
  5. 将 Room1 temperature 更改为 9
  6. 具有相同的输出,但 [...{"timesSent"=&gt;3}..., ...{"timesSent"=&gt;3}..., ...{"timesSent"=&gt;5}...]

【问题讨论】:

  • 您能否编辑您的答案以包含GET /v2/subscriptions 操作的输出,好吗?谢谢!
  • 编辑了答案,添加了 GET /v2/subscriptions 操作的输出,
  • 查看结果,注意只有最后一个订阅(574716a22fe8cdc00a696a96)应该timesSent和lastNotification,即似乎只有最后一个被触发了...
  • 让我们看看您收到的通知有效负载...您能否编辑您的问题以包含您收到的通知有效负载(由相应的更新触发),好吗?谢谢!
  • 我添加了一个场景并输出结果。这就是你想要的吗?

标签: fiware fiware-orion


【解决方案1】:

这是由于 Orion 1.1 中的订阅缓存管理存在问题。因此,该版本的解决方案是使用 -noCache CLI option 禁用缓存。

该错误已被识别并a github issue has been created about it。它将在更新的 Orion 版本中得到修复。

编辑:该错误已在开发分支中解决,因此它将在 Orion 1.2 中准备就绪,将于 2016 年 6 月上旬发布。

【讨论】:

  • 编辑关于 Orion 1.2 的错误修复
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多