简体   繁体   中英

Consume RESTFull service and insert them into Context broker

I have an external service that provides weather data via Restfull API with authentication. What would be the best option to able to consume the services and send/insert the data to a Context broker. I was thinking to develop a custom IoT Agent with json file to provide the external Restfull service endpoint and configuration for the Context broker. Is any other option to achieve the same functionality?

The big question here is whether you need to inject the data into the context broker, or just inform the context broker that such data exists. If you want to consider the weather station as a device, then indeed, your proposed architecture makes sense:

  1. Create a chron job to fire periodically
  2. Generate a file in a known format (eg JSON) and pass the file to a custom micro-service
  3. The micro-service interprets the file and runs a batch upsert to send all the data as measures into the context broker

An example of this with a code walkthrough is discussed in the following webinar

The alternative would be to create a micro-service which listens to the registration endpoint(s) - for NGSI-v2 uses the /v2/op/query batch endpoint for this, for NGSI-LD it is a direct forwarding of a request. In this scenario, the weather-station data remains outside of the context broker itself and can be used to augment existing entities. A working example can be found within the FIWARE Tutorials

Obviously the route you choose will depend upon what you need to do with the data, if you need to subscribe to temperature changes for example, then it is better to treat the weather station as a device providing context data in the form of measures and go for Option 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM