Is there any way to create a subscription in Orion Context Broker to notify any changes in the context, but only notify those attributes that have changed?
At the moment, the only way I found to do this is to create several subscriptions, each one pointing to changes in a certain attribute of the context and notifying only that attribute (similar to what is said here). The problem is that this solution is not maintainable in practice because you need to create as many subscriptions as attributes in the context.
Any help?
Attributes to include in notifications are controlled by the attrs
or exceptAttrs
fields in notification
(see NGSIv2 specification for details). Thus, current options are "all attributes", "all attributes except a fixed list" or "a fixes list of attributes".
However, note this issue in Orion repository. I think is exactly what you mean. Feel free adding comments to that issue or stating your support to it.
EDIT: A workaround would be to use previousValue
metadata. Thus, you can subscribe for all attributes (using "attrs": [ ]
or omitting the field) including previousValue
metadata in notifications (using "metadata": [ "previousValue" ]
). So, your notifications receiver knows if an attribute has actually changed, just comparing the value of the attribute and the value of the previousValue
metadata.