1. Right click on src/main/rules and select the Rules Resource and click on the Next button

2. Give the Rule Name and package name and click finish which will create new business Rule file with template

Below is the new Rules template file which

Every rule will be starting with rule keyword and then name of the rule. Condition will be starting with “when” keyword and then “action” keyword to process the action. We can define the rules group or salience which prioritize the execution of rules which I will explain in my next section.

3. Will create simple rule i.e. length of member of metadata should be 6.

It represents that “Cost Center” rule which belong to rule flow-group “group1” uses the Metadata POJO object which assign into variable m and check the condition if length of member is 8 then show the message that Cost Center Metadata is valid.

m.setMessage(..) can be used to set the message and later can be accessed into Client or Test class.

1. Right click on src/main/rules and select other which will open the new Flow file wizards.

2. Select the “Flow File” and click next which will move to next screen where you can give the Rule flow file name click finish which creates the new Flow File with component bar on left side.

3. Select the Rule task and place into rule drawing pane.

4. Open the Rule flow property and give the name of the Rule task and link it to with rule putting group1 on RuleFlowGroup section. If you remember we have add the rule flow group as group1 which will link rule flow with Cost Center rul.

I can assume we have understood how to create the simple BRMS rules and test the same. In this section I would try to explore the complex rules creation. We will also learn how to prioritize & routing of rules using the rules flow. We will also see the proper use of Rule flow group.

Below code depicts the different rules have been created to cater the above validation. If you see carefully explored then you will find that I grouped rules in different group’s group1, group2 and group3.In this way we can instruct to the rules engine to run the group of rules separately.

We branched rule in three category i.e. CC, FE & Else. If dimension is CC then executes the CC related rules i.e. group1. if dimension is FE then execute FE related rule i.e. group2. If dimension is neither CC nor FE then execute Else part of the rule i.e. group3.

1.Create the new rule file

2.Select the” Start” & “End” component and add into pane

3.Add the Gateway diverge

4.Add 3 “Rule Task” components in the pane as mentioned in below figures.
5. Add the Gateway Converge as mentioned in the below figure

6.Select the Gateway diverge properties and select the Type as “OR”

7.Click on the Constraints which will open “Edit Constraints” window

8.Click on First Node Entity enter the name “FE”, Type “rule” and Dialect as “java”

9.Enter the Metadata (dimension=”FE”) in the Textual Editor

10.This would add the routing for FE dimension

11.Similar way Edit the Constraint for CC

12.Similar way Edit the Constraint for Else

13.Select the Cost Center(CC) Rule Task property enter the name Cost Center and RuleFlowGroup as “group1”

14.In the similar way add the RuleFlowGroup for FE and group2 and Else group3.