Describe Routing Rule

It has three services:

1) Get All rules

2) Get Rule by ID

3) Get Associated routing key

Get All Rules

This service is used to get all the routing rules created by a tenant. There are two ways for getting all MR rules:

  • Using MR API swagger

  • Using MR portal

Using MR API swagger

Following is the URL for describing all routing rules in MR. It can also allow to filter based on rule name and/or rule description.

  • GET http://<domain name>/MessageRouting/v2.0/routingRules?RuleName={RuleName}&RuleDescription={RuleDescription}

  • Following is the sample output body JSON for getting MR rules:

[{
     "Status": "Created",

     "RuleID": 1,
     "RuleName": "TEST RULE",
     "RuleDescription": "TEST RULE",
     "parallelismFactor": 1,
     "input": {
         "DirectExchange": "Direct.Exchange",
         "RoutingKey": "key#test"
     },
     "params": [{
             "name": "feature",
             "value": "health*"
         },
         {
             "name": "sensorID",
             "value": "^[a-zA-Z0-9]*$"



         },
         {
             "name": "time",
             "value": {
                 "starttime": "23-JUL-2013 15:30:00 IST",
                 "endtime": "24-JUL-2013 15:30:00 IST"
             }
         },
         {
             "name": "expression",
             "value": {
                 "if": "",
                 "then": "",
                 "else": ""
             }
         },
         {
             "name": "ObservedProperties",
             "value": [{
                 "name": "systolic",
                 "value": "!(10,20)",
                 "type": "quantity",
                 "operator": ""
             }]
         }
     ],
     "output": {
         "TopicExchange": "testTopic",
         "Topic": "test.*"
     }
 },
 {
     "Status": "Stopped",
     "RuleID": 2,
     "RuleName": "R99",
     "RuleDescription": "R99",
     "parallelismFactor": 1,
     "input": {
         "DirectExchange": "Direct.Exchange",
         "RoutingKey": "uKK6WjaZZnnYBj1G6rONQgNAIuc="
     },
     "params": [{
             "name": "feature",
             "value": ""
         },
         {
             "name": "sensorID",
             "value": "sensor2"
         },
         {
             "name": "time",
             "value": {
                 "starttime": "",
                 "endtime": ""
             }
         },
         {
             "name": "expression",
             "value": {
                 "if": "temp>80",
                 "then": "return \"high \";",
                 "else": "return \"low \";"
             }
         },
         {
             "name": "ObservedProperties",
             "value": [{
                     "name": "diastolic",
                     "value": "90",
                     "type": "quantity",
                     "operator": ">"
                 },
                 {
                     "name": "systolic",
                     "value": "80",
                     "type": "quantity",
                     "operator": "!="
                 }
             ]
         }
     ],
     "output": {
         "TopicExchange": "test123",
         "Topic": "test"
     }
 }
]
../../_images/routingrule1.jpg

Using MR portal

Home page of MR portal displays the list of created MR rules by a tenant. User can click on any rule to expand and perform operation on it as shown in the image below:

../../_images/routingrule5.jpg

Get Rule by ID

This service is used to get a particular routing rule with its rule ID created by a tenant. There are two ways for getting rule by ID:

  • Using MR API swagger

  • Using MR portal

Using MR API swagger

Following is the URL for describing a routing rule by ID in MR:

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

  • Following is the sample output body JSON to get MR rule by ID:

{
 "Status": "Created",
 "RuleID": 1,
 "RuleName": "testMeta25",
 "RuleDescription": "testMeta25",
 "parallelismFactor": 3,
 "input": {
     "DirectExchange": "Direct.Exchange",
     "RoutingKey": "uKK6WjaZZnnYBj1G6rONQgNAIuc="
 },
 "params": [{
         "name": "feature",
         "value": "health*"
     },
     {
         "name": "sensorID",
         "value": "testSMeta"
     },
     {
         "name": "time",
         "value": {
             "starttime": "23-JUL-2013 15:30:00 IST",
             "endtime": "24-JUL-2013 15:30:00 IST"
         }
     },
     {
         "name": "expression",
         "value": {
             "if": "",
             "then": "",
             "else": ""
         }
     },
     {
         "name": "ObservedProperties",
         "value": [{
             "name": "temp",
             "value": "30",
             "type": "quantity",
             "operator": ">"
         }]
     },
     {
         "name": "meta-data",
         "value": [{
                 "name": "speedometer-version1",
                 "value": "^abc$",
                 "type": "text",
                 "operator": ""
             },
             {
                 "name": "speedometer-version",
                 "value": "^xyz$",
                 "type": "text",
                 "operator": ""
             }
         ]
     }
 ],
 "output": {
     "TopicExchange": "testExchange",
     "Topic": "testMeta25.*"
 }
}
../../_images/routingrule2.jpg

Using MR portal

You can use MR portal to view the rule by rule ID as shown below:

../../_images/routingrule6.jpg

After selecting the search by ID, type the rule ID in the text box:

../../_images/routingrule7.jpg

After rule is searched by ID expand the Action tab and click on View button to view the rule:

../../_images/routingrule8.jpg

Get Associated Routing Keys

This API is used to list associated Routing Keys available for a tenant. These Routing keys are mentioned in MR rule while a rule is created.

  • GET http://<domain name>/MessageRouting/v2.0/routingChannel/RoutingKeys

  • Click on GET routingChannel/RoutingKeys API in swagger and hit Try it out! button, it will list all the routing keys assoicated with all MR rules created by user as shown in the image below:

../../_images/MR_routing_key.jpg