-
Notifications
You must be signed in to change notification settings - Fork 265
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 sent on identical data when JSON attribute values are used #4211
Comments
Thank you for your issue report! Pretty clear and straightforward :) We have recently solved a problem that sounds similar to the one you describe.
However, that fix has not been yet released (it is planned for Orion 3.8.0, which is the next version) Could you test with |
Great! I will test (tomorrow) and give feedback! Thanks! |
All the same :-( |
For completeness, this is, what I'm currently trying: {
"description": "MG",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Vehicle",
}
]
,
"condition":{
"attrs":["test_attribute"]
}
},
"notification": {
"http": {
"url": "http://quantumleap:8668/v2/notify"
},
"attrs": [
"test_attribute"
],
"onlyChangedAttrs": true
} And the payload, sent via "PUT" after a first "POST": {
"test_attribute": {
"type": "Text",
"value": "test"
}
} I will try some more things (e.g. using POST with upsert, switch from normailzed to keyValues) in the next days... |
Comparing floating point values is a difficult task in a program. I ran into the same problem with Orion-LD and my idea of solving it (haven't implementing it yet) is to use a range for floating point comparisons and not an exact comparison. Instead of comparing with EXACT numbers:
I'd do an AND:
Then the question arrives, WHO exactly defines the precision? |
Just to be sure... could you do a |
@fgalan The output is: {
"orion" : {
"version" : "3.7.0-next",
"uptime" : "0 d, 2 h, 18 m, 47 s",
"git_hash" : "90d592b1293645f43cb12af49fe128c3e7aedb7a",
"compile_time" : "Thu Sep 1 12:17:37 UTC 2022",
"compiled_by" : "root",
"compiled_in" : "d30c3c23186e",
"release_date" : "Thu Sep 1 12:17:37 UTC 2022",
"machine" : "x86_64",
"doc" : "https://fiware-orion.rtfd.io/",
"libversions": {
"boost": "1_74",
"libcurl": "libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3",
"libmosquitto": "2.0.12",
"libmicrohttpd": "0.9.70",
"openssl": "1.1",
"rapidjson": "1.1.0",
"mongoc": "1.17.4",
"bson": "1.17.4"
}
}
} @kzangeli You're right and the "solution" (in C++) is EPSILON. But as I mentioned before...the problem here is not related to that thingy... |
What I did before (I'm using a Node-RED flow), is sending the above payload to Orion Context Broker using the verb PUT (id and type in URL and not in payload) and on a 404 (entity not found - cannot update), I added id and type to the payload and sent it via POST. Next time, the same id can be updated via PUT. {
"test_attribute": {
"type": "Number",
"value": 10.1
}
} does not work (always notifying - even on identical values): {
"test_attribute": {
"type": "geo:json",
"value": {
"type": "Point",
"coordinates": [10.2, 10.0]
}
}
} |
Maybe the problem is related which the usage of JSON values in attributes. By the above report, it seems it is not related with numbers exclusively. Could you test the following case and report the result, please? Case 1:
Case 2:
|
Here we go: OKAY: let simple = {
"test_attribute": {
"type": "Number",
"value": 10.1
},
}; FAIL: let geo = {
"test_attribute": {
"type": "geo:json",
"value": {
"type": "Point",
"coordinates": [10.2, 10.0]
}
},
}; FAIL: let object_ = {
"test_attribute": {
"type": "noMatter",
"value": {
"x": "a",
"y": "b"
}
},
}; FAIL: let array_ = {
"test_attribute": {
"type": "noMatter",
"value": [ "x", "y" ]
},
}; Conclusion: |
Not so sure Orion supports "check of value change for compound value". It's ... a bit complex. I implemented it myself for Orion-LD - by rendering the old vs rendering the new value, then just a simple strcmp() ... To do it well, you'd need to order all fields of the compound values (old and new - recursively), and after that you can compare As I said, a bit complex That said, float comparisons, if not done with a range (GE AND LE) will give problems as well, as I stated earlier. |
Great "idea"! |
If the parser you use supports ordering of fields, then yes, of course. You still might have a problem with Arrays. Anyway, best effort, right? I mean:
is not necessarily the same as:
|
If Orion uses std::array<string, 2> as1 {"a", "b"};
std::array<string, 2> as2 {"b", "a"};
cout << "Arrays are equal? " << as1 == as2;
|
Had it been that simple ... Either you compare the old tree with the new tree (recursively looking up members from tree 1 in tree 2, and then mark every field as "compared", afterwards make sure all fields were compared in both trees), or you sort and render and strcmp. It is possible to implement, though, I did it myself. It's just a bit of work ... Array will always be a problem though. We'd need an option somewhere for the comparison, sometyhing expression "pay attention to array order" |
The solution to this issue would be to implement "deep compare" in attribute value JSON structures. Orion uses an internal way of representing JSON (CompoundValue) so some recursive function should be implemented to do so. The feedback in the previous comments can be useful to that end. I'm changing the title to describe more precisely the issue. (I think this is not the first time we find this and even there is an old issue about this. However, I haven't been able to find it among the open issues). |
Yes, correct. |
Just to have an answer to my client...Do you think, this will be implemented in 3.8.0? ...and further: is there a release date planned yet? |
It would depend if (and when) some brave developer volunteers to implement it :) By the moment it is [not] ours immediate priorities. You can always use a side not-JSON attribute that changes at the same time than the JSON one (typically, a "TimeInstant" attribute of type DateTime with the timestamp of the change).
Maybe you can ask budget to your client so you can allocate resources to contribute with it. I understand your client could be an interested party in getting this functionality done ;) |
Okay. About the contribution: That project is about evaluating the FIWARE stack -the customer wants to know, if it fits his needs - so no money for development here :-( ... And as a reminder for the fix: Keep in mind, that the condition acts differently, depending on how the Orion Context Broker is used. PUT/POST or POST with upsert. (See my comment above) |
Note that if you split latitude and longitude into two different attributes instead of using GeoJSON, you will not be able to benefic from the geo-query features in Orion.
Pitty :(
Your comment will be taken into account when this issue gets addressed. Thanks for all your valuable feedback! |
Hello everyone, any news about this problem with GEO:JSON? We are having a lot of problems with the new version of orion:3.7.0 and the coordinates. Would it perhaps be possible to use checks from the turf library to validate that the geo:json's are different? https://github.com/Turfjs/turf/tree/master/packages/turf-boolean-equal https://libgeos.org/ - Symmetric Difference Br, |
Based on the previous analysis (see all the discussion above) it seems is not a problem with geo:json in particular, but with any JSON used as attribute value. As I told before:
Maybe you would like to implement the fix (given that is seems you have a strong use case needing it)? I'd be more than happy to review your pull request and provide feedback and guidance on it :) Finally, you say "a lot or problems with the new version of orion:3.7.0 and the coordinates". Two comments:
Thanks for your feedback! |
Whenever I run the request to the informed endpoint, the entity is received by the subscription, regardless of having changes or not.
In order not to receive notifications constantly, we are using coordinates in the geo:point format and this way we don't have the problem of receiving them all the time.
Sometimes we have much more complex coordinates like MultiPoint, MultiPolygon or MultiLineString As our integrations with external services are designed to receive data via NIFI, we have not implemented a logic to validate field by field before sending it to the broker and in many cases the data does not change. |
Related issue #4434 (similar problem in metadata) |
PR #4444 |
It was #643 :) |
A fix for this problem has been provided (in master branch by the time being). The version of Orion available in @WillFreitag @JeffersonLupinacci it would be great if you could test with that version an provide feedback (either if the issue is solver or not), please. Thanks! |
Orion 3.11.0 is about to be released. Thus, we are closing this issue. Of course it could be reopened if @WillFreitag and/or @JeffersonLupinacci feedback comes in the future. |
Bug description
Orion sends a notifier, even if no attribute is changed.
How to reproduce it
Steps to reproduce the behavior (as an example)
Expected behavior
The notification is only fired on attribute change.
Additional information
The text was updated successfully, but these errors were encountered: