Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications fired allways even if not watchedAttribute changes #1224

Closed
javicond3 opened this issue Sep 1, 2022 · 7 comments
Closed

Notifications fired allways even if not watchedAttribute changes #1224

javicond3 opened this issue Sep 1, 2022 · 7 comments

Comments

@javicond3
Copy link

javicond3 commented Sep 1, 2022

Notifications sent even if the watchedAttribute does not change. I reproduce the issue with the following example:

  1. Create the entity:
curl -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/create' \
-H 'Content-Type: application/ld+json' \
--data-raw '[
{
   "id":"urn:ngsi-ld:AirQualityObserved:Guadalajara:ES1537A",
   "type":"AirQualityObserved",
   "pm10":{
      "type":"Property",
      "value": 1
   },
   "so2":{
      "type":"Property",
      "value": 2
   },
   "@context": ["https://smartdatamodels.org/context.jsonld"]
}
]'
  1. Create the subscription (it should fire when the pm10 attribute changes):
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
-H 'Content-Type: application/ld+json' \
--data-raw '{
  "description": "A subscription to get air quality",
  "type": "Subscription",
  "entities": [{
    "type": "AirQualityObserved"
    }],
  "watchedAttributes": [
      "pm10"
    ],
  "notification": {
    "endpoint": {
      "uri": "http://localhost:3000/ld/notify",
      "accept": "application/json"
    }
  },
    "@context": "https://smartdatamodels.org/context.jsonld"
}'
  1. Update the entity (the so2 attribute so the notification should not be fired):
curl -iX PATCH 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:AirQualityObserved:Guadalajara:ES1537A/attrs' \
-H 'Content-Type: application/ld+json' \
--data-raw '{
   "so2":{
      "type":"Property",
      "value": 40
   },
   "@context": ["https://smartdatamodels.org/context.jsonld"]
}'
  1. Result: I receive the notification ❌
  2. Expected: The notification should not be sent
@kzangeli
Copy link
Collaborator

kzangeli commented Sep 2, 2022

That's exactly what you should expect.
If you think of it a little, the value might not have been modified, but the "modifiedAt" has - meaning the value is new, not "old" anymore and this is important info for the temporal database.

That said, it's not interesting for everybody and if you start Orion-LD with the CLI -noNotifyFalseUpdate then the notification will not be sent.
This will be a field in the subscription and not a global flag for the broker ... some day. We've already discussed this in ETSI ISG CIM where we define the NGSI-LD API.

So, try that CLI and close the issue if it is working as you propose/expect.

Thanks for reporting, even though this time it seems to be a "false positive" :)

@kzangeli
Copy link
Collaborator

kzangeli commented Jan 8, 2023

Hi again.
A colleague of mine stumbled upon this issue the other day and it seems like I misread the issue.
I answered on a non-related topic.
Sorry about that. Seems like I concentrated on the update and not o the "watchedAttributes" of the subscription.
So, I'll look into this. If what you are reporting is true, it's an important bug that I need to fix asap.

Just one doubt.
What are the CLI parameters you use when starting the broker?

@kzangeli
Copy link
Collaborator

kzangeli commented Jan 9, 2023

So, I've seen the bug and I've seen that you are not using the -experimental CLI param (or its corresponding env var ORIONLD_EXPERIMENTAL).
It works as it should when -experimental is used, so, while the bug should be fixed, it's old code, using the old deprecated driver for mongo.
The new implementation (turned on with the -experimental CLI param) uses the newest driver for mongoc and once the broker has been enough tested, the "experimental" mode will be set as default.

So, I'd propose you start using -experimental mode and see how it goes. It's a step in the right direction

@javicond3
Copy link
Author

Thanks,

I will try it with the experimental mode.

@kzangeli
Copy link
Collaborator

kzangeli commented Jan 9, 2023

It's not as "experimental as it sounds.I have ~500 functersts that make sure it's all working.
It was "experimental" in the very beginning, when I named the cli option

@pierre-josselin
Copy link

pierre-josselin commented Dec 15, 2023

I encounter exactly the same problem (Orion-LD 1.1.2). I have a single subscription with the watched attribute temperature, but when only humidity attribute is changed, the notification is still sent. I enabled ORIONLD_EXPERIMENTAL=TRUE which did not fix the problem.

@kzangeli
Copy link
Collaborator

kzangeli commented Dec 17, 2023

I enabled ORIONLD_EXPERIMENTAL=TRUE which did not fix the problem.

ok, that's interesting.
However, @javicond3 closed the issue, I assume he did that because he was happy with it.
Orion-LD 1.1.2 is rather old.
Please try with a newer version of the broker and if you still see the error, then
post the complete info I need to be able to reproduce.

This should be enough:

  • Complete CLI params for the broker,
  • the payload body of the creation of the subscription,
  • the URL+body of the update that provokes the non-wanted notification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants