Fiware Orion context broker subscriptions condition does not work

风格不统一 提交于 2019-12-30 11:13:30

问题


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"=>{}}
}

I did not have any subscription.

Then I created 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"}}}
}
]

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

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

But it does not work as it should !!!

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

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

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

Edit: 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: Add some scenario:

  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}...]

回答1:


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.

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

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



来源:https://stackoverflow.com/questions/37437225/fiware-orion-context-broker-subscriptions-condition-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!