Buffer Rule¶
Buffer based MR rule is created when there is no filtering condition for input JSON data. Any input JSON with a valid format can be processed in MR.
The create rule JSON on the buffering condition is mentioned below:
{
"RuleName": "Demo rule buffer",
"RuleDescription": "Demo rule for user guide",
"input": {
"DirectExchange": "Direct.Exchange",
"RoutingKey": "e325f4fe-a0e3-4252-82af-4c24deb8c0cf"
},
"params": [
{
"name": "feature",
"value": ""
},
{
"name": "sensorID",
"value": ""
},
{
"name": "time",
"value": {
"starttime": "",
"endtime": ""
}
},
{
"name": "expression",
"value": {
"if": "",
"then": "",
"else": ""
}
},
{
"name": "",
"type": "rectangle/circles/polygon",
"geoFencing": "YES/NO",
"value": {
"points": [
{
"x": "",
"y": ""
},
{
"x": "",
"y": ""
}
]
}
},
{
"name": "ObservedProperties",
"value": [
{
"name": "",
"type": "Text/quantity/count",
"value": "",
"operator": ""
}
]
}
],
"output": {
"TopicExchange": "DemoExchange",
"Topic": "demo1"
}
}
We can see that there is no condition provided for the input data in the JSON mentioned above. Input data is routed with any input JSON and output data is given to the output Topic Exchange. The Topic exchange name is DemoExchange which we have already created in the topic exchange section.
We will now create the rule mentioned above in the following two ways:
Using MR API swagger
Using MR portal
Using MR API swagger¶
Click on POST /routingRules API in swagger, use the above JSON template and hit
Try it out!
button, it will create a new MR rule with feature as shown in the image below:
As we can see in the above image MR rule created with rule ID - 1111 will be used to start this rule. We can refer to start rule API to start rule.
Using MR portal¶
Click on
Create Rule
button in MR rule, fill in all the details as mentioned in the image below and clickCreate Rule
button, it will create a new MR rule with feature as shown in the image below:
After clicking
Create Rule
button the message mentioned below will be dispalyed at the upper right corner with rule ID. In our case rule ID is 1113.
We can see the MR rule created with rule ID - 1113 in the image mentioned above. This rule ID will be used to start the rule. We can refer to start rule through the MR portal to start the rule.