-->

Fiware: NGSI v2 susbcription: getting notified onl

2019-07-30 18:36发布

问题:

I have this subscription:

{
    "id": "5a27abba56256c402cec5654",
    "description": "my subscription",
    "status": "active",
    "subject": {
        "entities": [
            {
                "idPattern": ".*"
            }
        ],
        "condition": {
            "attrs": []
        }
    },
    "notification": {
        "timesSent": 56939,
        "lastNotification": "2018-01-29T09:06:45.00Z",
        "attrs": [],
        "attrsFormat": "normalized",
        "http": {
            "url": "http://notif_url"
        },
        "lastFailure": "2018-01-24T15:10:08.00Z",
        "lastSuccess": "2018-01-29T09:06:45.00Z"
    }
}

Using it I can get notified about new entities whithout specifiying a particular entity ID. The problem is that when one entity attribute changes I get notified about all attributes. Is it possible to get notified only about the attribute that has changed and keeping in the same time the possibility to discover new entities?

Something like in if attribut x changed in the condition part, get notified about it:

 "condition": {
                "attrs": [attribute_X]
            }
 "notification": {
            "attrs": [attribute_X]
}

Thanks!

回答1:

It works the way you mention. I mean, using:

"condition": {
  "attrs": [ "attribute_X" ]
}
...
"notification": {
   "attrs": [ "attribute_X" ]
}

Whenever attribute named attribute_X changes (or appears first time, typically at entity creation time) you will receive a notification including only attribute_X