【发布时间】:2021-05-10 11:58:53
【问题描述】:
我正在尝试将 Context Provider 注册为多个 KPI 的来源。
到目前为止,似乎注册可能有效,因为 GET http://{{orion}}/v2/registrations 返回的内容类似于我在创建时设置的内容:
{
// each registering a new id is returned: "id": "60991a887032541f4539a71d",
"description": "City Inhabitants",
"dataProvided": {
"entities": [
{
"id": "city.inhabitants"
//,"type": "KeyPerformanceIndicator"
}
]
},
"provider": {
"http": {
"url": "http://myhost/v2/inhabitants"
}
//, "legacyForwarding": false //perhaps there's a bug, cause although unset or set to false, broker still returns true.
}
}
但是 GET http://{{orion}}/v2/entities/city.inhabitants 会导致:
{
"error": "BadRequest",
"description": "Service not found. Check your URL as probably it is wrong."
}
GET http://{{orion}}/v2/entities?type=KeyPerformanceIndicator 返回 [] 并且不会以任何方式调用 context-provider。
我正在从头开始编写 Node.js 应用程序,以便更好地了解 https://github.com/FIWARE/tutorials.Context-Providers 的情况,并使用教程容器作为实际的 Fiware Broker,因此所有 stores/shelf/products 都在工作但不是我的 KPI。
【问题讨论】:
-
"entities": [{"id": "city.inhabitants","type": "KeyPerformanceIndicator"}]表示只有id和type的组合才会返回任何内容。尝试删除id或使用正则表达式 -
legacyForwarding将以 NGSI-v1 格式返回 - 这不再是必需的 -
@JasonFox 关于 legacyForwarding:根据github.com/telefonicaid/fiware-orion/issues/…,如果未设置应为 false,但代理仍返回 legacyForwarding=true。也许它是一个错误?
-
可能,我的意思是您的示例中不需要它,现在可以忽略。
-
@JasonFox 不是 id+type 的用法需要同时使用两者,如 fiware-orion.readthedocs.io/en/master/user/context_providers/… 所述,这是一种好的做法? > 在转发时,NGSIv2 更新/查询中的任何类型的实体都匹配没有实体类型的注册。但是,相反的方法不起作用,因此如果您注册了类型,那么您必须在 NGSIv2 更新/查询中使用 ?type 以获得匹配。否则你可能会遇到问题,就像 StackOverflow 上的这篇文章中描述的那样。
标签: fiware fiware-orion