Open daniel-gonzalez-sanchez opened 2 months ago
Hi Dani,
I just checked the specification and it is not as explicit as I thought regarding the explanation of the showChanges feature. The original intention was to show what change triggered the notification, i.e. only the triggering attribute would have a previousX subproperty. With this assumption, it is clear that you do not see a previousValue in a notification to a periodic subscription as notifications are triggered by time, not by the update of an attribute. I acknowledge that currently the spec is not very clear about it - so clarifications need to be added. Possibly, we could also decide to extend the feature to explicitly show updated values also for cases where the notification was not triggered by this change. This will require a good cost - benefit analysis.
Martin
Hi,
just to add my 2 cents from the technical side. Currently interval subs can't get the previous value at all. they would need to store it in the DB since multiple instances of the sub man need to be aware of a change and on every interval everyone has to pull again from the DB ... i would say normally not a big problem but in a big case with lots of subs or lots of data in the notification and a fast interval you might end up with a delay bigger then your interval ... just for completeness sake... onchange on the other side will be triggered by message which can in all cases include the previous value from the DB directly so there it is always there
Thanks again for your quick answer and clarifications!
Following the ETSI CIM standard and the specification document for the NGSI-LD API, it was not clear to me wether the showChanges
feature would be valid or not for periodic subscriptions and it seemed that it was something global for any type of subscription (i.e. periodic or change-based). Thanks for the details about the original intention of this feature and about the technical side. I understand the problem of the showChanges
feature in periodic subscriptions, however I think that from the point of view of users or consumers there could be practical applications in using this for periodic subscriptions.
Also, note the last comment of the previous message that for notifications on periodic subscriptions that configure the sysAttrs
feature, when there is an update to the subscribed entity the modifiedAt
system-generated attribute has a datetime with precision of seconds instead of milliseconds. That is, the first notifications resulting from the creation of the entity have a modifiedAt
with millisecond precision but as soon as there is an update within the entity the precision is changed to seconds. I have observed this with the sysAttrs
feature set and with or without the showChanges
feature set.
Thanks again!
Hi everyone,
I was playing again with NGSI-LD subscriptions in order to check the resolution of previously closed issues #522 and #523 regarding
sysAttrs
andshowChanges
notification parameters in subscription operations when I discovered a new issue. I've discovered that theshowChanges
notification parameter works for on-change subscriptions but does not work for periodic subscriptions.Let me show an example:
Environment
Steps to reproduce Creating a subscription based on changes to a sample
TemperatureSensor
NGSI-LD Entity with theshowChanges
andsysAttrs
notification parameters:If we request all the committed subscriptions with the following query:
, the regarding response body is the following:
Creating a sample
TemperatureSensor
NGSI-LD Entity with atemperature
Property that includes anunitCode
attribute as additional metadata to indicate the unit of measurement of the temperature value:, the first notification received by the consumer is the following one:
The notification includes the
createdAt
andmodifiedAt
attributes thanks to thesysAttrs
notification parameter, and theunitCode
attribute is included within thetemperature
Property. And if we commit a Partial Attribute Update for thetemperature
Property with a new temperature value:, the second notification received by the consumer is the following one:
As we can see, the behavior is as expected for the on-change subscription with the
showChanges
notification parameter and we get in the notification both the previous and current value of thetemperature
Property.Let's repeat the process with a periodic subscription. Creating a periodic subscription to a sample
TemperatureSensor
NGSI-LD Entity with atimeInterval
parameter equal to 10 seconds and with theshowChanges
andsysAttrs
notification parameters configured:If we request all the committed subscriptions with the following query:
, the regarding response body is the following:
Creating a sample
TemperatureSensor
NGSI-LD Entity with atemperature
Property that includes anunitCode
attribute as additional metadata to indicate the unit of measurement of the temperature value:, the first notification received by the consumer is the following one:
The notification includes the
createdAt
andmodifiedAt
attributes thanks to thesysAttrs
notification parameter, and theunitCode
attribute is included within thetemperature
Property. But for this first notification, it does not include thepreviousValue: @none
attribute. And if we commit a Partial Attribute Update for thetemperature
Property with a new temperature value before the 10-seconds period of the following notification is met:, the second notification received by the consumer is the following one:
As you can see, the behavior is not as expected for the periodic subscription with the
showChanges
notification parameter since the notification does not appear with the previous value (i.e., thepreviousValue
attribute) inside thetemperature
Property.We can also observe how, for some reason, in the second notification the
modifiedAt
system-generated attribute no longer has more than seconds precision instead of milliseconds. Also, in this case, unlike with on-change subscriptions, thecreatedAt
system-generated attribute appears both inside and outside the temperature Property in the notifications (this issue is also discussed in open issue #608).Thanks again!
Dani