1

I am trying to save historical context data in Mongo, but without success. Only the first payload sent to Draco is saved to MongoDB for historical data, but Mongo does not react to attribute updates. Versions used for the test: Orion-LD version 0.8.0, Mongo version 4.4, Draco version 1.3.6. I tested it also with the 3.4 version of Mongo and the behavior is the same.

Can you, please, help me to fix a problem?

Below are the steps I performed:

Create a Draco subscription:

curl --location --request POST 'http://localhost:1026/v2/subscriptions' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /openiot' \
--header 'Content-Type: application/json' \
--data-raw '{
  "description": "Notify Draco of all context changes",
  "subject": {
    "entities": [
      {
        "idPattern": ".*"
      }
    ]
  },
  "notification": {
    "http": {
      "url": "http://10.0.0.5:5050/v2/notify"
    }
  },
  "throttling": 0
}'

Create an entity:

curl --location --request POST 'http://localhost:1026/v2/entities' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /openiot' \
--header 'Content-Type: application/json' \
--data-raw ' {
      "id":"urn:ngsi-ld:Product:0102", "type":"Product",
      "name":{"type":"Text", "value":"Lemonade"},
      "size":{"type":"Text", "value": "S"},
      "price":{"type":"Integer", "value": 99}
}'

Overwrite the value of an attribute value:

curl --location --request PUT 'http://localhost:1026/v2/entities/urn:ngsi-ld:Product:0102/attrs' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /openiot' \
--header 'Content-Type: application/json' \
--data-raw '{
    "price":{"type":"Integer", "value": 110}
}'

LISTEN_HTTP PROCESSOR: LISTEN_HTTP

NGSITOMONGO PROCESSOR:NGSITOMONGO

Template: Template

MongoDB: mongo

dacak
  • 60
  • 5
  • 2
    I see you're using the NGSIv2 API, how come you use Orion-LD and not Orion? I wouldn't really recommend it ... – kzangeli Feb 22 '22 at 12:51
  • That was one of the requirements, but I will keep that in mind, thank you for that. I also tested with Orion version 3.4.0 but even that doesn't solve the problem I have. When I used Mysql for the database I had no problems, but we need to use Mongo. – dacak Feb 22 '22 at 13:28
  • Not an issue with the broker then - it's all draco. I'll try to find an expert on draco to take a look at this. – kzangeli Feb 24 '22 at 15:29
  • Thank you, it would mean a lot to me. I really appreciate your help. – dacak Feb 28 '22 at 11:27
  • The Draco team have being working on a new release for fixing this bug. The 2.1.0 release of Draco is now available, in the official repository and also has the docker images. – anmunoz Mar 07 '22 at 01:23

2 Answers2

2

We do not use that precise stack, but we have got many production deployments keeping context historical data on MongoDb by using FIWARE Orion (v2 API) with FIWARE Cygnus (NGSIMongo Sink for historical raw data, and NGSISTH Sink for aggregated data at MongoDB).

https://github.com/telefonicaid/fiware-cygnus/blob/master/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_mongo_sink.md

https://github.com/telefonicaid/fiware-cygnus/blob/master/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_sth_sink.md

Maybe this help.

Perrolobo
  • 543
  • 3
  • 14
  • 1
    Thank you very much for your answer. Could you tell me how to save multiple entities at once in the historical Mongo database using Cygnus? Is this possible with Cygnus? Here is the full question: https://stackoverflow.com/questions/71338124/multiple-entities-cant-be-saved-at-same-time-in-mongo-historical-database – dacak Mar 04 '22 at 13:35
1

In the new version of Draco 2.1.0 this bug is fixed. You can check the code in the official repository. The release link is https://github.com/ging/fiware-draco/releases/tag/2.1.0

Additionally, you can use the docker image available for this release by pulling it using docker pull ging/fiware-draco:2.1.0.

You can also use the Mongo-Tutorial template available inside of Draco where you have preconfigured the processors needed to persist in MongoDB.

One thing that you have to consider is that the new version of Draco is aligned with the 1.15.3 version of NiFi in where you need first to log in for access to the Web UI using the default credentials (user: admin, password: pass1234567890). You can check the official documentation for more information about it https://fiware-draco.readthedocs.io/en/latest/

anmunoz
  • 131
  • 6