1

I am using "onlyChangedAttrs" = true in my Draco subsciption, but it doesn't seem to be working. It is still sending all the attributes irrespective of it is modified or not. Does this feature work in a particular version of Orion? However I am using the latest version of Orion "2.4.0-next". Can you please help me fix this. Thanks for your help! My draco subscription attached here:

  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 
}'

Also the payload sent to Draco after an attribute is modified is attached below (please note all attributes sent though we modified only the attribute named "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":{

            }
         }
      }
   ]
}

Version details of Orion: GET /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/"
}
}

Output of /v2/subscriptions:

[
   {
      "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
      }
   }
]

And below is the JSON from mongodb -> orion schema -> csubs collection:

{
   "_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"
} 
Kavipriya M
  • 131
  • 5
  • Hint: it would be better if you provide the curl in text form instead of using a snapshot (that way it would be easy to debug for other, eg. copy pasting from your question post to a debug environment). – fgalan May 05 '20 at 20:31
  • In order to clarify your setup, it would be good to know: 1) the output of `GET /v2/subscriptions` for that service and servicepath, 2) the payload of the notification you get (you can temporarily stop Draco and run `nc` or similar tool on the same port to get the notification). Please edit your question post to include that information. Thanks! – fgalan May 05 '20 at 20:33
  • You have included the notification recevied by Draco in the question post. Great! However, the following piece of information is still missing: "the output of GET /v2/subscriptions for that service and servicepath". Please include also that. Thanks! – fgalan May 06 '20 at 15:01
  • Moreover, to be fully precise (as 2.4.0-next is a moving picture :), could you provide also the response of `GET /version` in the CB API, please? Thanks! – fgalan May 06 '20 at 15:01
  • @fgalan - I have added all the details as requested by you, the Orion Version and the Subscription details. Can you please help. Thanks! – Kavipriya M May 13 '20 at 14:04

1 Answers1

0

Note that subscription you get in both GET /v2/subscriptions and MongoDB (with ID 5eb3e7fa331ff6cb547598e1) is not the same is causing the notification (with ID 5eb290700d76dc473d3a5ace). Moreover, subscription 5eb3e7fa331ff6cb547598e1 has never been triggered (in that case a counter with the number of notification sent and the timestamp of the last notification should be shown).

Thus, my theory is that another subscription (maybe in a different Context Broker) is causing your notifications and that subscription is probably not using onlyChangedAttrs.

EDIT: it seems there is an issue with the onlyChangedAttrs feature when subs cache is used. An issue will be created in the Orion code repository and eventually solved. In the meanwhile, using -noCache can be used as workaround.

EDIT2: issue created at Orion repository: https://github.com/telefonicaid/fiware-orion/issues/3906

EDIT3: this issue has been solved in Orion version 3.2.0

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • Hi Fgalan, We have multiple instances of Fiware in different environment, so I copy/pasted the subscription details from a different subscription hence the discrepancy above, my apologies for it. We have however made some progress on this issue. After we added the "-noCache" option to Orion, onlyChangedAttrs is working fine. If we do not give this -noCache option, onlyChangedAttrs does not work. – Kavipriya M May 19 '20 at 10:39
  • We further noticed that when Caching is enabled, the first time after the Draco subscription is created onlyChangedAttr works for the first payload, but the second time onwards it stops working. So from all this, we feel the issue is closely related to Caching. Can you please help investigate further on this and give us a resolution. Thanks! – Kavipriya M May 19 '20 at 10:44
  • Also for now we have decided to go with -noCache option to overcome this issue. Can you please let us know what would be the overall implications if we disable Caching. – Kavipriya M May 19 '20 at 10:47
  • One more question on subscriptions - all static attributes on entity are still sent as part of the Draco payload even if they are not modified, is there anyway to restrict static_attributes from being sent please. Thanks! – Kavipriya M May 19 '20 at 11:09
  • Hi Fermin, Can you please help us on this issue please. – Kavipriya M May 26 '20 at 14:43
  • After some testing, it seems there is an issue with the onlyChangedAttrs when subs cache is used. An issue will be created in the Orion code repository and eventually solved. Thanks for the feedback! – fgalan Dec 29 '20 at 11:15
  • With regards to *"Can you please let us know what would be the overall implications if we disable Caching"* I'd recommend you to have a look to https://stackoverflow.com/questions/43857300/what-would-be-the-behavior-of-subscriptions-and-notifications-in-an-orion-load-b/43873643#43873643 – fgalan Dec 29 '20 at 11:20
  • With regards to *"One more question on subscriptions - all static attributes on entity are still sent as part of the Draco payload even if they are not modified, is there anyway to restrict static_attributes from being sent please"* I'd recommend you to open a new question for that, please. – fgalan Dec 29 '20 at 11:21
  • New information added to answer post, see EDIT2 – fgalan Aug 13 '21 at 11:04
  • New information added to answer post, see EDIT3 – fgalan Sep 08 '21 at 07:49