Skip to content

Commit f7b914c

Browse files
authored
Merge pull request #1607 from telefonicaid/task/allow_send_update_cb_batch_for_multimeasures
allow to send to CB batch update for multimeasures (and sort them by TimeInstant)
2 parents eae5ae0 + 6d8642b commit f7b914c

6 files changed

Lines changed: 956 additions & 352 deletions

File tree

‎CHANGES_NEXT_RELEASE‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (telefonicaid/iotagent-json#827)
1+
- Fix: allow send multiple measures to CB in a batch (POST /v2/op/update) and sorted by TimeInstant when possible, instead of using multiples single request (iotagent-json#825, #1612)
2+
- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (iotagent-json#827)

‎doc/api.md‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Measurement transformation order](#measurement-transformation-order)
3333
- [Multientity measurement transformation support (`object_id`)](#multientity-measurement-transformation-support-object_id)
3434
- [Timestamp Processing](#timestamp-processing)
35+
- [Multimeasure support](#multimeasure-support)
3536
- [Overriding global Context Broker host](#overriding-global-context-broker-host)
3637
- [Multitenancy, FIWARE Service and FIWARE ServicePath](#multitenancy-fiware-service-and-fiware-servicepath)
3738
- [Secured access to the Context Broker](#secured-access-to-the-context-broker)
@@ -1051,6 +1052,127 @@ Some additional considerations to take into account:
10511052
measure of after a mapping, as described in the previous bullet) then it is refused (so a failover to server
10521053
timestamp will take place).
10531054

1055+
## Multimeasure support
1056+
1057+
A device could receive several measures at the same time.
1058+
1059+
For example:
1060+
1061+
```json
1062+
[
1063+
{
1064+
"vol": 0
1065+
},
1066+
{
1067+
"vol": 1
1068+
},
1069+
{
1070+
"vol": 2
1071+
}
1072+
]
1073+
```
1074+
1075+
In this case a batch update (`POST /v2/op/update`) to CB will be generated with the following NGSI v2 payload:
1076+
1077+
```json
1078+
{
1079+
"actionType": "append",
1080+
"entities": [
1081+
{
1082+
"id": "ws",
1083+
"type": "WeatherStation",
1084+
"vol": {
1085+
"type": "Number",
1086+
"value": 0
1087+
}
1088+
},
1089+
{
1090+
"id": "ws",
1091+
"type": "WeatherStation",
1092+
"vol": {
1093+
"type": "Number",
1094+
"value": 1
1095+
}
1096+
},
1097+
{
1098+
"id": "ws",
1099+
"type": "WeatherStation",
1100+
"vol": {
1101+
"type": "Number",
1102+
"value": 1
1103+
}
1104+
}
1105+
]
1106+
}
1107+
```
1108+
1109+
Moreover if a multimeasure contains TimeInstant attribute, then CB update is sorted by attribute TimeInstant:
1110+
1111+
For example:
1112+
1113+
```json
1114+
[
1115+
{
1116+
"vol": 0,
1117+
"TimeInstant": "2024-04-10T10:15:00Z"
1118+
},
1119+
{
1120+
"vol": 1,
1121+
"TimeInstant": "2024-04-10T10:10:00Z"
1122+
},
1123+
{
1124+
"vol": 2,
1125+
"TimeInstant": "2024-04-10T10:05:00Z"
1126+
}
1127+
]
1128+
```
1129+
1130+
In this case a batch update (`POST /v2/op/update`) to CB will be generated with the following NGSI v2 payload:
1131+
1132+
```json
1133+
{
1134+
"actionType": "append",
1135+
"entities": [
1136+
{
1137+
"id": "ws",
1138+
"type": "WeatherStation",
1139+
"vol": {
1140+
"type": "Number",
1141+
"value": 2
1142+
},
1143+
"TimeInstant": {
1144+
"type": "DateTime",
1145+
"value": "2024-04-10T10:05:00Z"
1146+
}
1147+
},
1148+
{
1149+
"id": "ws",
1150+
"type": "WeatherStation",
1151+
"vol": {
1152+
"type": "Number",
1153+
"value": 1
1154+
},
1155+
"TimeInstant": {
1156+
"type": "DateTime",
1157+
"value": "2024-04-10T10:10:00Z"
1158+
}
1159+
},
1160+
{
1161+
"id": "ws",
1162+
"type": "WeatherStation",
1163+
"vol": {
1164+
"type": "Number",
1165+
"value": 0
1166+
},
1167+
"TimeInstant": {
1168+
"type": "DateTime",
1169+
"value": "2024-04-10T10:15:00Z"
1170+
}
1171+
}
1172+
]
1173+
}
1174+
```
1175+
10541176
## Overriding global Context Broker host
10551177

10561178
**cbHost**: Context Broker host URL. This option can be used to override the global CB configuration for specific types

0 commit comments

Comments
 (0)