我按照关于天鹅座和猎户座的官方文件 . 所有通用启用程序都已正确部署,其日志文件中没有错误 . 但是一些奇怪的事情发生了,猎户座永远不会通知天鹅座 .
为了测试这个机制,我按照官方文档中提供的Car实体的示例进行了操作 .
我的实体创建bash脚本:
(curl $1:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"contextElements": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1",
"attributes": [
{
"name": "speed",
"type": "integer",
"value": "75"
},
{
"name": "fuel",
"type": "float",
"value": "12.5"
}
]
}
],
"updateAction": "APPEND"
}
EOF
我的实体订阅bash脚本:
(curl $1:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: vehicles' --header 'Fiware-ServicePath: /4wheels' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
}
],
"attributes": [
"speed",
"oil_level"
],
"reference": "http://$2:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"speed"
]
}
],
"throttling": "PT1S"
}
EOF
我的实体更新bash脚本:
(curl $1:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"contextElements": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1",
"attributes": [
{
"name": "speed",
"type": "integer",
"value": $2
}
]
}
],
"updateAction": "UPDATE"
}
EOF
Note :猎户座响应所有请求 .
执行这些脚本后,cygnus必须从orion接收报告的信息并将其保存在数据库中,但没有任何反应 . 在/var/log/cygnus/cygnus.log文件或/var/log/contextBroker/contextBroker.log文件中都不会报告有关orion通知的任何信息 .
Note :如果我使用官方文档中提供的notify.sh脚本,Cygnus运行良好并将所有数据保存在数据库中 .
Note :我在其他问题中读到了有关开放端口的问题,但那些不适用于我的 .
EDIT 1
在我订购了猎户座之后,回复是:
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "563e12b4f4d8334d599753e0",
"throttling": "PT1S"
}
}
当我更新alntity时,orion返回它:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "integer",
"value": ""
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
要从orion获取实体,我使用了以下脚本:
(curl $1:1026/v1/queryContext -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
}
]
}
EOF
响应:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "fuel",
"type": "float",
"value": "12.5"
},
{
"name": "speed",
"type": "integer",
"value": "123"
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Note 速度值已成功更新 .
1 回答
考虑到订阅请求中的
Fiware-Service
和Fiware-ServicePath
标头,它已在服务"vehicles"的"/4wheels"服务路径中执行 . 但是,实体创建请求不使用此类标头,因此它是在默认服务的默认服务路径("/")中创建的 . 因此,订阅不是实体,因此实体中的更新不会触发通知 .该问题的一个解决方案是在订阅的相同服务和服务路径中创建实体,即服务“车辆”的“/ 4轮”服务路径 .
请查看Orion关于service和service path概念的官方文档 .