【发布时间】:2021-09-22 16:37:22
【问题描述】:
我很难理解上下文提供程序在 Orion 上下文代理中的工作方式。 我按照 Jason Fox 编写的分步指南中的示例进行操作。但是,我仍然不完全了解后台发生的情况以及上下文代理如何从注册中准确创建 POST。这是我想要做的:
我确实有一个气象站,可以为社区提供传感器数据。
{
"id": "urn:ngsi-ld:WeatherStation:001",
"type": "Device:WeatherStation",
"temperature": {
"type": "Number",
"value": 20.5,
"metadata": {}
},
"windspeed": {
"type": "Number",
"value": 60.0,
"metadata": {}
}
}
现在我喜欢 WeatherStation 成为所有建筑物的上下文提供者。
{
"id": "urn:ngsi-ld:building:001",
"type": "Building"
}
这是我尝试使用的注册。
{
"id": null,
"description": "Random Weather Conditions",
"provider": {
"http": {
"url": "http://localhost:1026/v2"
},
"supportedForwardingMode": "all"
},
"dataProvided": {
"entities": [
{
"id": "null",
"idPattern": ".*",
"type": "Building",
"typePattern": null
}
],
"attrs": [
"temperature",
"windspeed"
],
"expression": null
},
"status": "active",
"expires": null,
"forwardingInformation": null
}
上下文代理接受实体和注册,没有任何错误。
因为我有一个多租户设置,所以我使用一个fiware_service 来表示整个社区,但以后每栋建筑都会有一个单独的fiware_servicepath。因此,气象站具有与建筑物不同的服务路径。尽管我也尝试将它们放在同一条路径上。
现在我对所有实体使用相同的标题。
{
"fiware-service": "filip",
"fiware-servicepath": "/testing"
}
这里是上下文代理的日志(版本:3.1.0):
INFO@2021-09-23T19:17:17.944Z logTracing.cpp[212]: Request forwarded (regId: 614cd2b511c25270060d873a): POST http://localhost:1026/v2/op/query, request payload (87 bytes): {"entities":[{"idPattern":".*","type":"Building"}],"attrs":["temperature","windspeed"]}, response payload (2 bytes): [], response code: 200
INFO@2021-09-23T19:17:17.944Z logTracing.cpp[130]: Request received: POST /v2/op/query?options=normalized%2Ccount&limit=1000, request payload (55 bytes): {"entities": [{"idPattern": ".*", "type": "Building"}]}, response code: 200
日志说它收到请求并按预期转发。但是,据我了解,这只会再次指向同一个建筑实体。因此,它在某种程度上是一个循环转发。我也无法告诉任何有关请求标头的信息。
我不明白来自建筑物的转发请求如何实际向气象站查询信息。当我查询我的建筑物时,我仍然只收到没有自己属性的实体:
{
"id": "urn:ngsi-ld:building:001",
"type": "Building"
}
我也尝试更改注册的网址,但没有成功。
- 当前的实现真的可以实现这种情况吗?这将非常有用
- 是否有任何示例包括标题?
我知道我可以简单地使用参考,但这会给用户带来更多的工作。
感谢您对此的任何帮助。
【问题讨论】:
-
您在注册时使用了单个建筑物的 id ...您不想为所有建筑物提供服务吗?删除 id 并保留类型:Building。而且,究竟出了什么问题?请确保注册和实体在同一个租户(相同的固件服务)
-
@kzangeli 谢谢你的 hin。我试图根据您的评论调整我的有效负载,但仍然没有运气。我开始相信我的情况是不可能的。 ://
-
我不确定您的设置...您是否将 ContextBroker 本身注册为上下文提供者?这不是通常的设置... Context Provider 曾经是 ContexBroker 的外部系统。如果可以直接在 ContextBroker 本身中查询注册信息,那么将 ContextBroker 注册为“自助提供者”有什么意义呢?我想我错过了一些东西:)
标签: fiware fiware-orion