Create Routing Rule

This group of API is used for operation on MR routing rules such as create MR rule, update MR rule, get MR rules, get MR rule by ID and delete MR rule. We will discuss these APIs in detail.

This service is used to create the routing rule for a tenant. A user can create a wide variety of MR rules with different routing and filtering conditions depending on which an input data can be filtered and routed to the output topic exchange. The following is the URL for MR create rule:

  • POST http://<domain name>/MessageRouting/v2.0/routingRules

  • The following is the default template for creating MR Rule:

{
             "RuleName": "",
             "RuleDescription": "",
             "parallelismFactor": "1",
             "input": {
                     "type": "Direct",
                     "DirectExchange": "",
                     "RoutingKey": "",
                     "MQName": ""
             },
             "params": [
                     {
                             "name": "feature",
                             "value": ""
                     },
                     {
                             "name": "sensorID",
                             "value": ""
                     },
                     {
                             "name": "time",
                             "value": {
                                     "starttime": "",
                                     "endtime": ""
                             }
                     },
                     {
                             "name": "expression",
                             "value": {
                                     "if": "",
                                     "then": "",
                                     "else": ""
                             }
                     },
                     {
                             "name": "position",
                             "type": "rectangle/circles/polygon",
                             "geoFencing": "NO",
                             "value": {
                                     "points": [
                                             {
                                                     "x": "",
                                                     "y": ""
                                             },
                                             {
                                                     "x": "",
                                                     "y": ""
                                             }
                                     ]
                             }
                     },
                     {
                             "name": "ObservedProperties",
                             "value": [
                                     {
                                             "name": "",
                                             "type": "Text/quantity/count",
                                             "value": "",
                                             "operator": ""
                                     }
                             ]
                     },
                     {
                             "name": "meta-data",
                             "value": [
                                     {
                                             "name": "",
                                             "value": "",
                                             "type": "text/quantity/count",
                                             "operator": ""
                                     }
                             ]
                     },
                     {
                             "name": "parameter",
                             "value": [
                                     {
                                             "name": "",
                                             "value": "",
                                             "type": "text/quantity/count",
                                             "operator": ""
                                     }
                             ]
                     },
                     {
                             "name": "quality",
                             "value": [
                                     {
                                             "name": "",
                                             "value": "",
                                             "type": "text/quantity/count",
                                             "operator": ""
                                     }
                             ]
                     }
             ],
             "output": {
                     "TopicExchange": "",
                     "Topic": ""
             }
     }
  • Description of create rule JSON parameter is defined in the table below:

    Parameter

    Required

    Values

    Description

    RuleName

    true

    string

    RuleName should be unique for every rule.

    RuleDescription

    true

    string

    It should be the a short description about the rule functionality.

    parallelismFactor

    true

    numeric value

    It should be in the range of 1-10 which defines the parallelism factor.

    Input:type

    false

    string

    Type of the exchange. Possible values are Direct or topic or mq. Default is Direct.

    Input:DirectExchange

    false

    string

    Name of the direct exchange through which the input json is received in MR through SOS/DM. Default is Direct.Exchange

    Input:RoutingKey

    false

    string

    It is the routing key through which the data is routed to direct exchange of MR.Default is x-api-key.

    Input:MQName

    false

    string

    Name of the queue when type parameter’s value is mq.

    feature

    false

    string

    It is the name of observation feature on which feature based filtering is done.

    sensorID

    false

    string

    It is the name of observation sensor on which sensor based filtering is done.

    start time

    false

    time with date format

    It is the start time for input json

    end time

    false

    time with date format

    It is the end time for input json

    expression

    false

    if,then,else

    if then else condition like “if”: “systolic>80”, “then”: “return “high”;” “else”:”return “low”;”.It can also have nested if else condition like: “if(systolic< 80 && systolic> 50 ) {return “medium”;} else {if(systolic> 20){return”low”;}}”

    position rectangle

    false

    cordinates with north east and south west

    It is position based filtering of rectangle geographical area.

    position circle

    false

    coordinates of circle center and radius in mt,mile,km

    It is position based filtering of circle geographical area.

    position polygon

    false

    coordinates of all polygon points

    It is position based filtering of polygon geographical area.

    position geoFencing

    true

    YES/NO

    It is an additional feature which creates an alert on first exit(breach) or entry in enclosed area(above 3) for input SOS json.

    ObservedProperties

    false

    string

    It is observation output property filtering of type test, quanity and count type.

    meta-data

    false

    string

    It is observation mata data property filtering of type test, quanity and count type.

    parameter

    false

    string

    It is observation parameter property filtering of type test, quantity and count type

    quality

    false

    string

    It is observation quality property filtering of type test, quantity and count type.

    output:TopicExchange

    true

    string

    It is the topic exchange to which the output of MR is posted.Output should always be posted to a topic exchange.

    output:Topic

    true

    string

    It is the topic name associated with Topic Exchange to which the output of MR is routed.

Note

The output of a MR rule is published on a topic exchange therefore before creating the rule, a user needs to create the exchange. To create an exchange click here Create Exhange.

MR supports the following variety of filtering conditions: