Mongo 历史数据库中无法同时保存多个实体
Multiple entities can't be saved at same time in Mongo historical database
我试图在历史数据库中保存多个数据实体,但 Mongo 历史数据库中只保存了数组中的第一个。
以下是我执行的步骤。
Docker-为天鹅座作曲:
version: "3.8"
services:
cygnus:
hostname: cygnus
container_name: cygnus
image: fiware/cygnus-ngsi:2.16.0
networks:
- default_config
ports:
- "5080:5080"
- "5051:5051"
expose:
- "5051"
- "5080"
environment:
- CYGNUS_MONGO_SERVICE_PORT=5051
- CYGNUS_MONGO_HOSTS=mongo_db:27017
- CYGNUS_MONGO_USER=root
- CYGNUS_MONGO_PASS=root
- CYGNUS_MONGO_AUTH_SOURCE=admin
- CYGNUS_MONGO_DATA_MODEL=dm-by-service-path
- CYGNUS_MONGO_ATTR_PERSISTENCE=column
- CYGNUS_SERVICE_PORT=5051
- CYGNUS_API_PORT=5080
- CYGNUS_LOG_LEVEL=DEBUG
- CYGNUS_ORION_HOST=orion
- CYGNUS_ORION_PORT=1026
- CYGNUS_ORION_SSL=true
networks:
default_config:
external: true
创建 Cygnus 订阅:
curl --location --request POST 'http://localhost1026/v2/subscriptions' \
--header 'Content-Type: application/json' \
--data-raw '{
"description": "Notify Cygnus Mongo-DB of all context changes",
"subject": {
"entities": [
{
"idPattern": ".*"
}
]
},
"notification": {
"http": {
"url": "http://10.0.0.5:5051/notify"
}
},
"throttling": 5
}'
批量创建新数据实体:
curl --location --request POST 'http://localhost:1026/v2/op/update/' \
--header 'Content-Type: application/json' \
--data-raw '{
"actionType":"append_strict",
"entities":[
{
"id":"urn:ngsi-ld:Product:100", "type":"Product",
"name":{"type":"Text", "value":"Brandy"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:101", "type":"Product",
"name":{"type":"Text", "value":"Port"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1099}
}
]
}'
结果Mongo:
组更新也不起作用。
我是否遗漏了配置中的某些内容,或者在 Cygnus 中不可能有?
提前致谢。
第一印象。订阅时您使用的是:"throttling": 5
throttling: Minimal period of time in seconds which must elapse
between two consecutive notifications. It is optional.
这意味着每 5 秒只会发送一个通知 window。通过您的 NGSIv2 批量更新,所有通知肯定会在 5 秒内出现 window。
尝试删除 属性。
我试图在历史数据库中保存多个数据实体,但 Mongo 历史数据库中只保存了数组中的第一个。 以下是我执行的步骤。
Docker-为天鹅座作曲:
version: "3.8"
services:
cygnus:
hostname: cygnus
container_name: cygnus
image: fiware/cygnus-ngsi:2.16.0
networks:
- default_config
ports:
- "5080:5080"
- "5051:5051"
expose:
- "5051"
- "5080"
environment:
- CYGNUS_MONGO_SERVICE_PORT=5051
- CYGNUS_MONGO_HOSTS=mongo_db:27017
- CYGNUS_MONGO_USER=root
- CYGNUS_MONGO_PASS=root
- CYGNUS_MONGO_AUTH_SOURCE=admin
- CYGNUS_MONGO_DATA_MODEL=dm-by-service-path
- CYGNUS_MONGO_ATTR_PERSISTENCE=column
- CYGNUS_SERVICE_PORT=5051
- CYGNUS_API_PORT=5080
- CYGNUS_LOG_LEVEL=DEBUG
- CYGNUS_ORION_HOST=orion
- CYGNUS_ORION_PORT=1026
- CYGNUS_ORION_SSL=true
networks:
default_config:
external: true
创建 Cygnus 订阅:
curl --location --request POST 'http://localhost1026/v2/subscriptions' \
--header 'Content-Type: application/json' \
--data-raw '{
"description": "Notify Cygnus Mongo-DB of all context changes",
"subject": {
"entities": [
{
"idPattern": ".*"
}
]
},
"notification": {
"http": {
"url": "http://10.0.0.5:5051/notify"
}
},
"throttling": 5
}'
批量创建新数据实体:
curl --location --request POST 'http://localhost:1026/v2/op/update/' \
--header 'Content-Type: application/json' \
--data-raw '{
"actionType":"append_strict",
"entities":[
{
"id":"urn:ngsi-ld:Product:100", "type":"Product",
"name":{"type":"Text", "value":"Brandy"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1199}
},
{
"id":"urn:ngsi-ld:Product:101", "type":"Product",
"name":{"type":"Text", "value":"Port"},
"size":{"type":"Text", "value": "M"},
"price":{"type":"Integer", "value": 1099}
}
]
}'
结果Mongo:
组更新也不起作用。 我是否遗漏了配置中的某些内容,或者在 Cygnus 中不可能有?
提前致谢。
第一印象。订阅时您使用的是:"throttling": 5
throttling: Minimal period of time in seconds which must elapse between two consecutive notifications. It is optional.
这意味着每 5 秒只会发送一个通知 window。通过您的 NGSIv2 批量更新,所有通知肯定会在 5 秒内出现 window。
尝试删除 属性。