本文介绍了Fiware Orion上下文代理订阅条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Orion Context Broker 1.1.0版

I am using Orion Context Broker version 1.1.0

我在数据库中只有一个实体:

I had the only entity in my DB:

{
  "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 >, 温度== 10 .

As you can see, the difference is only in the expressions: temperature>10, temperature<10, temperature==10.

因此,每次更改 Room1 温度时,我只有一个subscription触发通知.

So that any time I change the Room1 temperature I should have only one subscription triggering the notification.

但是它不能正常工作!

每次更改温度时,我都会收到所有3条通知.

Each time I change the temperature, I have all 3 notifications.

但是,创建subscriptions时,只有其中一个触发了通知,具体取决于Room1的temperature值.它按预期工作.

However, when subscriptions were created, only one of them triggered a notification, depending on the temperature value of the Room1. It worked as expected.

但是Room1 temperature更改后,它将无法正常工作并触发所有3条通知.

But when Room1 temperature is changed, it does not work correctly and triggers all 3 notifications.

修改:GET/v2/subscriptions操作的完整输出:

Full output of the GET /v2/subscriptions operation:

[
  {
    "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"=>1}..., ...{"timesSent"=>1}..., ...{"timesSent"=>3}...]
  3. Room1 temperature更改为10
  4. 具有相同的输出,但是[...{"timesSent"=>2}..., ...{"timesSent"=>2}..., ...{"timesSent"=>4}...]
  5. Room1 temperature更改为9
  6. 具有相同的输出,但是[...{"timesSent"=>3}..., ...{"timesSent"=>3}..., ...{"timesSent"=>5}...]
  1. Changed Room1 temperature to 11
  2. Had the same output, but[...{"timesSent"=>1}..., ...{"timesSent"=>1}..., ...{"timesSent"=>3}...]
  3. Changed Room1 temperature to 10
  4. Had the same output, but[...{"timesSent"=>2}..., ...{"timesSent"=>2}..., ...{"timesSent"=>4}...]
  5. Changed Room1 temperature to 9
  6. Had the same output, but[...{"timesSent"=>3}..., ...{"timesSent"=>3}..., ...{"timesSent"=>5}...]

推荐答案

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

This is due to a problem in subscriptions cache management in Orion 1.1. So, the solution in that version is to disable cache using -noCache CLI option.

该错误已被识别,并且已为此问题创建了github问题 .它将在较新的Orion版本中修复.

The bug has been identified and a github issue has been created about it. It will be fixed in a newer Orion version.

编辑:该错误已在开发部门解决,因此可以在Orion 1.2中使用,该漏洞将于2016年6月上旬发布.

the bug has been solved in development branch, so it would be ready in Orion 1.2, to be release by early June 2016.

这篇关于Fiware Orion上下文代理订阅条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 20:28