Thursday, 22 September 2016

Rules In SOA 12C

Rules in SOA 12c



In some of the business cases, you may need a changing environment, where your decision can be change over the time and also a medium to complex decision taking mechanism.  This entire system is running on some 3-4 basic settings, lets explore them one by one.  This is our first post over the rules and we will continue to explore more deeper into further posts. In this post we are trying to complete a solution, where we are deciding that no employee should be having a salary of more then 10000 and less then 1500.

We agree that it can simple be achieved using the if block but we tried to keep the example simple to understand. 


1. Facts. 

If in a system you want to take decision there could be some data which is static and dynamic. Like if want to process an employee then salary of a new employee we are entering is dynamic data.  Then the input data which comes to rule from the BPEL or mediator knows as fact. Its the data which is input to the decision. 

    a)  XML Facts :- 
              Data generated from the xml schema is known as fact. this include the data which is coming from the BPEL or you can add any new structure.

   
   b) Java facts  and ADFC Facts :-
        Will be discussed in the future posts.

 
2. Functions. 
     These functions can be created using the scripting canvas provided to you and later can be used to in the rule for the data manipulation.


3.  Gobals :- 
    These are variables, which can be used inside the rules to deal with the data. In this example we have created two constants, which are min and max salary.


4. Decision Function :- 

    Decision functions are different functions or set of rules, you can build. Normally when you create a rule a decision function be created automatically. You can create more also group already built rules in the decision function.



5. Translations :-

   With rules if you want to change the language of any output, then you can use translations. But use is limited.


6. Data Explorer :-

  It tells you all the data type been used in the Rules.


Now coming to example, where we are using a rule to decide salary, if minimum or maximum salary restriction reach.



1. Create a simple SOA application SOAEmployeeDemoApp with empty Composite SOAEmployeeDemoProj project,  There are several parameter in the xsd but we are considering only.



2. Create a SOA Project and give the name as given below.



3. Use empty Composite  for the project to call.



4. Once done then add a BPEL process on the composite, exposed it as a service. Before creating the BPEL process copy the schema from the given project.




5. Now from the side take the rule and add it to the composite. Give the name as given below also choose input and output as a same type. as given below.




6. Once done OK your rules are create with all the appropriate files, now its time to configure a simple rule.

   a. Add two Globals Min and Max salary stating values 500 and 15000.
   b. Add a rule as given below to check min salary and modifying the salary if less then the min salary.





7. Once its done then we need to call it from the BPEL, add rule activity from the BPEL and then add inputs and ouputs as given in the next picture.


  8. Now add the input values to the parameters.


 9. Map the output values of the rules to BPEL variables.


10. This is how entire process will look like.






Running 

1. Now deploy this BPEL process on SOA 12c Server.  and then open the composite for testing. provide input only salary should be less then 500.



2. Post testing it will give salary as 500.


3. This will be error trace for the process.




 Download 

 Please download the application from the link.



 Exercise.

 1. Add a new rule stating salary is more the 15000 then it should limit to 15000.




In the next post we will take ValueSet and bucketsets in rules.