简体   繁体   English

使用 RESTFull 服务并将它们插入到 Context broker

[英]Consume RESTFull service and insert them into Context broker

I have an external service that provides weather data via Restfull API with authentication.我有一个外部服务,通过 Restfull API 提供天气数据并进行身份验证。 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.我正在考虑使用 json 文件开发自定义 IoT 代理,以提供外部 Restfull 服务端点和上下文代理的配置。 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创建一个 chron 作业以定期触发
  2. Generate a file in a known format (eg JSON) and pass the file to a custom micro-service以已知格式(例如 JSON)生成文件并将文件传递给自定义微服务
  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.另一种方法是创建一个微服务来侦听注册端点——对于 NGSI-v2,为此使用/v2/op/query批处理端点,对于 NGSI-LD,它是直接转发请求。 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可以在FIWARE 教程中找到一个工作示例

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.显然,您选择的路线将取决于您需要对数据做什么,例如,如果您需要订阅温度变化,那么最好将气象站视为以测量和 go 形式提供上下文数据的设备对于选项 1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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