Introduction:
Business Rule is the component of both Oracle SOA Suite and Oracle BPM Suite. Oracle Business Rule enables the business user to modify the business rules without taking help from developer or without interrupting business processes. It is basically a combination of IF-ELSE condition designed by Oracle SOA suite. Here IF part is conditions or pattern match and ELSE part is action. Business Rules has elements like facts, rulesets, bucketsets, decision table and it can be associated with BPEL process. Bucketset (Value set in SOA Suite 12C) is used to define a list of values or range of values of a specific type. Bucketset can be associated with a fact property. Business user can change the business rules in SOA Composer.
Example of General Rules in Business Rule Process:
This example will give idea of general rules based on IF-ELSE condition. If department is 10, then approval is required for processing and if department is 20, then approval is not required.
Follow the below steps to execute this example.
- Create a new SOA application and SOA project. Navigate to File -> New -> Application. Select SOA Application
- Enter application name a�?BusinessRuleApplicationa��
- Click on Next and enter project name a�?BusinessRuleDemoa��
- Click on Next and select composite type as a�?Composite With Business Rulea��
- a�?Create Business Rulesa�� wizard will open. Enter directory name a�?ApprovalRulea��
- Create input and output parameter. Click on green plus icon and select a�?Input Parametera��.
- Select deptId from emp.xsd as input parameter. First import the schema file into the current project.
- Click on OK and uncheck the checkbox a�?Maintain original directory structure for imported filesa��
- Select approvalReqd from emp.xsd as output parameter
- Click on OK and a�?ApprovalRule.rulesa�� file will be created and the below screen will be displayed. Navigate to Rule Set tab. Click on green plus icon beside a�?Rule Seta�� and create new rule set. Now create general rules under rule set. Click on green plus icon in a�?General Rulesa�� section.
- Below window will appear
- Click on a�?insert testa�� and select a�?simple testa��
- Click on 1st a�?operanda�� and select deptId.deptId
- Click on 2nd a�?operanda�� and enter a value 10
- Click on a�?insert actiona�� and select a�?assert newa��
- Select a�?targeta�� as a�?approvalReqda��
- Edit the property in a�?THENa�� section. Click on a�?edit propertiesa�� and select the value a�?truea�� for a�?approvalRequired
- Click on OK and Rule1 will look like the below screenshot. Create another rule for dept id 20. Click on green plus icon in the right top corner.
- Rule2 will be created below the Rule1
- Insert condition and action for dept id 20 like a�?Rule1′. Only change the a�?approvalRequireda�� value to a�?falsea��. Now a�?General Rulesa�� will be like below screenshot.
- Drag and drop a a�?BPEL Processa�� in the a�?Componentsa�� lane. Enter BPEL process name a�?BusinessRuleBPELProcessa�� and select template as a�?Asynchronous BPEL Processa��
- Connect BPEL process with the Business Rule. Now composite will look like this.
- Create a variable in BPEL process to hold the reply from the Business Rule. Click on variable icon in the main scope.
- Click on green plus icon to create new variable
- Enter variable name a�?approveReqa�� and select variable type as a�?Booleana��.
- Select a�?Business Rulea�� from SOA Components and drag and drop it in between a�?receiveInputa�� and a�?callbackClienta��
- Double click on a�?Rule1a�� and select a�?ApprovalRulea�� as Dictionary. Service and Operation will be selected automatically based on the value of Dictionary.
- Create input fact and output fact. Click on a�?Createa�� icon in the a�?Assign input Factsa�� tab. Select input payload of BPEL process in the a�?Froma�� part and select dept id in the a�?Toa�� part.
- Now input part will be like this
- Navigate to a�?Assign Output Factsa�� tab and create new output fact. Select approvalReqd in the a�?Froma�� part and select approvereq variable in the a�?Toa�� part
- Now output fact will be like this
- SelectA�a�?IFa�� activity from ‘Structured Activities’ in the component palette and drag and drop it below the Business Rule
- Click on If and add a condition ($approveReq = a�?TRUEa��) in the expression builder
- Drag and drop two a�?Assigna�� activity under a�?IFa�� and a�?ELSEa�� part
- Assign the value a�?Approveda�� in the a�?Assigna�� activity under a�?IFa�� part and assign the value a�?Not Approveda�� in the a�?Assigna�� activity under a�?ELSEa�� part. Refer the below screenshots
- Now BPEL process will look like below screenshot
- Deploy the project and test the project in the Enterprise Manager Console.
- Enter 10 as input value
- Click on a�?Test Web Servicea��
- Click on a�?Launch Flow Tracea�� to get the process flow of the SOA composite and the output value also.
- Click on a�?ApprovalRulea�� and check that Rule1 has fired as input value is 10.
- Click on a�?BusinessRuleBPELProcessa�� to view the output value
- Login to SOA Composer (http://localhost:7101/soa/composer). You can check all the rules from SOA composer. Click on a�?ApprovalRulea�� and check the rules that have created in this example. Business user can easily change the rules in SOA Composer without taking any help from any technical person.