Saturday, June 26, 2010

Business Rules in SOA Suite 11g

In this exercise we will create a simple bpel process and a simple rule engine and we will see how does it work.For this exercise we will use

SOA Suite 11.1.1.3
Jdeveloper 11.1.1.3

Create a new Project



Create a composite with BPEL



let it be a asynchronous BPEL process



Now a bpel process will open up,drag and drop a business rule in the bpel process in between the receive and callback activity

It will open up a gui ,click on create a new dictionary



In the next screen click on create a new input variable



Next screen again create a new process variable




choose the element variable as the input response to the bpel process



Similarly create output variable for process response also



ONce you will be done with this configuration you will come up with a screen like this



We have two option either to create a rule or to create a rule dictionary.

Rule dictionary is used when we have a number of rules to be implement but in our case its a simple test case so we will just create a simple if else rule

click on create a rule and create a simple rule that if input is 20 then output is arpit



Now go to your bpel process and drag and drop a asign activity in between the receive and rule engine and assign the input variable to the input variable for rule engine




Similarly drag and drop a assign activity and copy the output of rule engine to output variable of BPEL.


To make this process look logical i have created one file adapter also which will be triggered when ever correct input will come that is when ever input will be 20 rule will be validate and output will be generated as arpit and this output will write to a particular folder.So my whole bpel process will look something like this




and my composite will look like this



Now deploy this project to you server and test its functionality.


Again from SOA Suite 11.1.1.2 we have and excellent feature that we can dynamically change the rules,this can be done by a separate console called soa composer

You can log in to soa composer using the following url

http://host:managed server port/soa/composer

Log in to soa composer and open the rules



Now you can see the rule that you have crated earlier has come into the list ,select the rule and say open




You can verify the same details that we have mentioned during the designing phase of the process.

You can select the rule set and edit it to change the values as per you new configuration and commit the changes.

Hope this exercise will give you and idea about the use case of rules in soa suite 11g

Here we have defined only one business rules so if we will pass some other value as input instead of 20 we will get an error

<bpelFault><faultType> <message>0</message></faultType><operationErroredFault xmlns="http://xmlns.oracle.com/OracleRules1/OracleRules1_DecisionService_1"><part name="payload"><errorInfo xmlns="http://xmlns.oracle.com/OracleRules1/OracleRules1_DecisionService_1"><errorMessage>Fact not found in the rule engine working memory, rule session execution failed. The rule session 70001 failed because an instance of the fact com.oracle.xmlns.javacallout_jws.project2.bpelprocess1.ProcessResponse could not be found in the working memory of the rule session. This is most likely a rule modeling error. The decision service interaction expects the fact instance to exist in the working memory of the rule session. Check the rule actions in rule designer and make sure that a fact of the expected type is being asserted. If the error persists, contact Oracle Support Services. </errorMessage></errorInfo></part></operationErroredFault></bpelFault>

which is quite clear

No comments: