猎户座没有通知天鹅座
Orion doesn't notify Cygnus
我遵循了关于 cygnus 和 orion 的官方文档。所有通用启用程序均已正确部署,其日志文件中没有错误。但是奇怪的事情发生了,Orion 从来没有通知 Cygnus。
为了测试此机制,我按照官方文档中提供的 Car 实体示例进行了操作。
我的实体创建bash脚本:
(curl :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 :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://:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"speed"
]
}
],
"throttling": "PT1S"
}
EOF
我的实体更新bash脚本:
(curl :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":
}
]
}
],
"updateAction": "UPDATE"
}
EOF
注意:Orion 会响应所有请求。
执行这些脚本后,cygnus必须接收到orion上报的信息并保存到数据库中,但是没有任何反应。
/var/log/cygnus/cygnus.log 文件或 /var/log/contextBroker/contextBroker.log 文件中均未报告有关 orion 通知的任何信息。
注意:如果我使用官方文档中提供的notify.sh脚本,Cygnus运行良好,并将所有数据保存在数据库中。
注意:我在其他问题中读到有关开放端口的问题,但这些不适用于我的问题。
编辑 1
我订阅猎户座后,回复是:
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "563e12b4f4d8334d599753e0",
"throttling": "PT1S"
}
}
当我更新实体时,猎户座 returns 它:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "integer",
"value": ""
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
为了从 orion 获取实体,我使用了以下脚本:
(curl :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"
}
}
]
}
注意速度值更新成功。
考虑到订阅请求中的Fiware-Service
和Fiware-ServicePath
headers,已在服务"vehicles"的“/4wheels”服务路径中执行。但是,实体创建请求并没有使用这样的headers,所以它是在默认服务的默认服务路径(“/”)中创建的。因此,订阅不是 "covering" 实体,因此实体中的更新不会触发通知。
该问题的一个解决方案是在订阅的相同服务和服务路径中创建实体,即服务的“/4wheels”服务路径"vehicles"。
请查看有关 service and service path 概念的 Orion 官方文档。
我遵循了关于 cygnus 和 orion 的官方文档。所有通用启用程序均已正确部署,其日志文件中没有错误。但是奇怪的事情发生了,Orion 从来没有通知 Cygnus。
为了测试此机制,我按照官方文档中提供的 Car 实体示例进行了操作。
我的实体创建bash脚本:
(curl :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 :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://:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"speed"
]
}
],
"throttling": "PT1S"
}
EOF
我的实体更新bash脚本:
(curl :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":
}
]
}
],
"updateAction": "UPDATE"
}
EOF
注意:Orion 会响应所有请求。
执行这些脚本后,cygnus必须接收到orion上报的信息并保存到数据库中,但是没有任何反应。 /var/log/cygnus/cygnus.log 文件或 /var/log/contextBroker/contextBroker.log 文件中均未报告有关 orion 通知的任何信息。
注意:如果我使用官方文档中提供的notify.sh脚本,Cygnus运行良好,并将所有数据保存在数据库中。
注意:我在其他问题中读到有关开放端口的问题,但这些不适用于我的问题。
编辑 1
我订阅猎户座后,回复是:
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "563e12b4f4d8334d599753e0",
"throttling": "PT1S"
}
}
当我更新实体时,猎户座 returns 它:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "integer",
"value": ""
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
为了从 orion 获取实体,我使用了以下脚本:
(curl :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"
}
}
]
}
注意速度值更新成功。
考虑到订阅请求中的Fiware-Service
和Fiware-ServicePath
headers,已在服务"vehicles"的“/4wheels”服务路径中执行。但是,实体创建请求并没有使用这样的headers,所以它是在默认服务的默认服务路径(“/”)中创建的。因此,订阅不是 "covering" 实体,因此实体中的更新不会触发通知。
该问题的一个解决方案是在订阅的相同服务和服务路径中创建实体,即服务的“/4wheels”服务路径"vehicles"。
请查看有关 service and service path 概念的 Orion 官方文档。