3 changed files with 110 additions and 1 deletions
@ -0,0 +1,9 @@ |
|||
Fields templatization feature allows you to process the incoming messages with dynamic configuration by substitution templates specified in the configuration fields with values from message or message metadata. |
|||
|
|||
There are two types of rule node configuration templates defined. |
|||
|
|||
*$[messageKey]* - templates with square brackets used to extract value from the message. |
|||
|
|||
*${metadataKey}* - templates with curly brackets used to extract value from the message metadata. |
|||
|
|||
Note: *messageKey* and *metadataKey* are just samples of key names that might exist in the message or metadata. |
|||
@ -0,0 +1,101 @@ |
|||
#### Customer attributes node fields templatization |
|||
|
|||
<div class="divider"></div> |
|||
<br/> |
|||
|
|||
{% include rulenode/common_node_fields_templatization %} |
|||
|
|||
##### Example |
|||
|
|||
Let's assume that we have a customer-based solution where customer manage two type of devices: *temperature* and *humidity* sensors. |
|||
Additionally, let's assume that customer configured the thresholds settings for each device type. |
|||
Threshold settings stored as an attributes on a customer level: |
|||
|
|||
- *temperature_min_threshold* and *temperature_max_threshold* for temperature sensor with values set to *10* and *30* accordingly. |
|||
- *humidity_min_threshold* and *humidity_max_threshold* for humidity sensor with values set to *70* and *85* accordingly. |
|||
|
|||
Each message received from device includes: *deviceType* property in the message metadata |
|||
with either *temperature* or *humidity* value according to the sensor type. |
|||
|
|||
In order to fetch the threshold value for the further message processing you can define next mapping in the configuration: |
|||
|
|||
TODO: add node config screenshot instead of mapping below: |
|||
|
|||
source key -> target key |
|||
|
|||
${deviceType}_min_threshold -> min_threshold |
|||
|
|||
${deviceType}_max_threshold -> max_threshold |
|||
|
|||
Imagine that you receive message defined below from the *temperature* sensor |
|||
and forwarded it to the *customer attributes* node with configuration added above. |
|||
|
|||
- incoming message definition: |
|||
|
|||
```json |
|||
{ |
|||
"msg":{ |
|||
"temperature":32 |
|||
}, |
|||
"metadata":{ |
|||
"deviceType":"temperature", |
|||
"deviceName":"TH-001", |
|||
"ts":1685379440000 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
Rule node default configuration set to fetch data to the message metadata so the outgoing message would be updated to: |
|||
|
|||
```json |
|||
{ |
|||
"msg":{ |
|||
"temperature":32 |
|||
}, |
|||
"metadata":{ |
|||
"deviceType":"temperature", |
|||
"deviceName":"TH-001", |
|||
"ts":1685379440000, |
|||
"min_threshold":"10", |
|||
"max_threshold":"30" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
The same example for the *humidity* sensor: |
|||
|
|||
- incoming message definition: |
|||
|
|||
```json |
|||
{ |
|||
"msg":{ |
|||
"humidity":32 |
|||
}, |
|||
"metadata":{ |
|||
"deviceType":"humidity", |
|||
"deviceName":"HM-001", |
|||
"ts":1685379440000 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
Rule node configuration wasn't changed so the outgoing message would be updated to: |
|||
|
|||
```json |
|||
{ |
|||
"msg":{ |
|||
"humidity":77 |
|||
}, |
|||
"metadata":{ |
|||
"deviceType":"humidity", |
|||
"deviceName":"HM-001", |
|||
"ts":1685379440000, |
|||
"min_threshold":"70", |
|||
"max_threshold":"85" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
This example showcases using the *customer attributes* node with dynamic configuration based on the substitution of metadata fields. |
|||
|
|||
|
|||
@ -1 +0,0 @@ |
|||
#### Coming soon! |
|||
Loading…
Reference in new issue