Showing posts with label OBR11g. Show all posts
Showing posts with label OBR11g. Show all posts

Saturday, December 18, 2010

Oracle Business Rules as a Composite Service

The general practice of using Oracle Business Rules is to create a set of rules in a dictionary and this dictionary in turn will be invoke by a bpel, which would have been exposed as a web service or composite service. But there are cases where a bpel is not needed and one needs the service of just rules.

In those particular cases, the dictionary themselves can be exposed as a composite service. So a web service would be created which would directly interface with the dictionary. A couple of points has to be noted when doing this and apart from that, its just a normal rules configuration, soa composite deploy and test:

Create an empty composite, just add a dictionary and make sure to mark the dictionary for the below:





































When testing the service, it would require the name of the decision function to be passed. Earlier this was taken care by the bpel when we used to drag drop the business rules component and choose the dictionary and decision function:











Cheers,
-AR

Thursday, September 30, 2010

Re-generation of facts fail when Java facts originating from same Schema exits

Re-generation of facts in a dictionary in Oracle Business Rules 11g is a simple step. One needs to just update the schema and reload the facts from the options available in the Fact tab of the dictionary. Unfortunately, I had been struggling for more than two weeks on this simple step and any change in schema, be it addition/deletion of an element or change in an element's type, the facts in the dictionary were so glued to the dictionary that, they refused to update !

I pondered over a lot of options and tried a lot of workarounds/suggestions:

  • Re-created the schema and imported the schema again into Jdeveloper
  • Cleaned the temporary files in windows which Jdeveloper creates, stores and uses, available under an user's profile
  • Reloaded the facts in the dictionary in a different package (not the default). This updated the facts but all the existing reference in the dictionary had errors in them
  • I even re-designed the schema based on one of my earlier posts
 All my efforts were futile and we had in the meanwhile a SR open with Oracle and we were getting some directions from them. Finally, Oracle found that we had been using a java fact created from the same schema  and imported via a jar, which was the issue!

Since the jaxb objects were the same, they was issue in refreshing the xml facts when a java fact belonging to same schema existed in the same dictionary. Below are the steps to be followed when a xml fact has to be refreshed (as in the case mentioned above):

  1. Exit Jdeveloper
  2. Remove the jar referenced to import the java fact (from hard disk)
  3. Start Jdeveloper, remove the jar from project reference
  4. Update the schema (preferably, open the schema and update contents instead of a replace of .xsd file)
  5. Save all artifacts and run a clean up (not necessary, just a feel good factor) from Build>CleanAll
  6. Reload facts from updated Schema and check for the same (in case not refreshed, close Jdeveloper and try cleaning workspace)
  7. Update the jar with the update schema and reference it in the project properties
Good to move on now !!

Peace!

Cheers,
-AR

Monday, September 13, 2010

Function to find age in years in Oracle Business Rules

I was part of a discussion recently - can age be found within business rules or can bpel do the math and get it for business rules. Business rules is not less incompetent and it does offer capability to mathematical calculations or so called numerical manipulations.

I had a date captured in a tag of type String and sent to business rules. I had to find the age from the date received in input. I have written a function in business rules that can get this done. Essentially the date is converted from string to date and then a difference in dates, will get you the result as an integer.

Duration.years between(OracleDate.from string(arg_1.IP1),RL.date.get current())










Peace!

Cheers,
-AR

Sunday, September 5, 2010

Schema design - when Schema is to be used for dictionary

Quite recently, I was struggling with an issue that Tree Mode in Oracle Business Rules was not working. This was not definitely the first time I was working with Tree Mode and I had used it before successfully. In the project where I noticed the issue, the tree mode expression assigned by JDeveloper was weird. Usually its the dots and slashes that you notice in a tree mode, but here, it was dollars.

For instance, consider an order having many order lines. When you refer to orderlinenumber within the order line, the tree mode in my project with issues looked like $Order$OrderLine$OrderLineNumber. In an usual case, it would have been Order/OrderLine.OrderLineNumber.

I then compared the project which worked fine with my current project. The issue was with the facts generated and hence the XSDs created in both the projects. The first project had a complex type defined for every element and that element had in its type the complex type definition. However, in the current project, there was no complex type defined and elements were defined individually and referenced within each other. This is still valid as per W3C standards. The XSD in both cases were as below:











The change in XSD also changed the way the facts were created. The facts in the first case were created based on the elements where as in the second case, it was the Complex types that was used by the Jaxb to create the facts !

Peace !

Cheers,
-AR

Tuesday, August 24, 2010

Compare between facts in condition

In Oracle Business Rules, it is usually the practice to validate a fact against a constant. But there might be cases where you would want to map the input from an user to one of fact, compare another fact with input from the user and make decisions. In other words, when the value of the constant to be issued in the condition is itself ambiguous, it is better to use the facts vs facts instead of facts vs constant method. For instance, I have a case where I have three inputs IP1, IP2 and IP3 coming in and I do not want to fix values (use constants for comparison in condition of rules) and instead make a condition directly involving IP1, IP2 and IP3. My schema in such a case will look like:

The decision table involving the facts will look like below:











The facts have been directly compared against each other without the need for a constant.

Peace!

Cheers,
- AR

Tuesday, August 10, 2010

The rete network does not update the modified data

This is a case where there is a dictionary D1 which is being invoked from BPEL. A set of facts F1, is passed to D1 and the same is returned from D1. There also exists D2, which uses the same set of facts as D1. D2 is invoked from the decision function of D1 (after D2 has been linked to D1, obviously !). I get F1 into D1 and I make a call to D2. D2 modifies F1 to F1.1 and returns call to D1. However, D1 does not understand F1 has changed to F1.1 and since it has been initialized with F1, continues to process the rules with F1 and F1.1 is not all considered.

This has been confirmed to be an inconsistent behavior from the rete network and rules engine and it has been identified as a bug. It would be fixed in the future releases (not sure of the release). Till if you face the same issue, you can survive with two workarounds:

A: Make call outs to rules from BPEL
  1. Call D1 from BPEL, execute rules in D1
  2. Instead of calling D2 from D1, call D2 from BPEL
  3. Then call D1 again. The rete network in this case initializes D1 with facts available in Step2
B: Assert the facts in D2 before returning control to D1
  1. Call D1, then D2 from decision function of D1
  2. Modify F1 to F1.1 in D2
  3. Using advanced functions do a assert and return of F1.1 (this makes the rete refresh the facts)
  4. Return control to D1 and proceed

Keep tracking this thread for the update on the bug and fix for the same !

Peace!

Cheers,
- AR

Monday, August 9, 2010

Reducing the size of dictionaries

I was working on a case study where I had to create close to 10 dictionaries, each of them having the same facts being passed to them. The XSD I was using was of a considerable size, say 27KB and the XML generated from it was 15KB. When the facts were created the dictionary size came to 1.3 MB. So since each of these dictionaries had facts imported in them, each was about 1.3 MB and so the entire .jar file post compiling was about 15 MB.

This was a simple 10 dictionaries in a project case. Consider 50-60 dictionaries and each of size 1 MB. The project would take about 20 minutes to deploy, considering my case study took 6 minutes to deploy. Maintenance becomes an issue here and SOA server after deployment becomes slow and unstable.

Alternative is, have the facts in one dictionary. Link this dictionary to all other dictionaries using the same facts and use the imported facts in rules. This reduces the size of the dictionaries considerably. Statistically, for my case study, the size of one of the dictionary (where facts were present) remained the same. The size of the others came down to 500KB (depends on decision table number, no.of rules etc) approx. The size of the entire deployable was halved.

Peace !

Cheers,
- AR

Wednesday, June 23, 2010

Fields with type int and decimal when sent in the input to Rules do not out come as in input

I created a BPEL Process which receives a XML payload which has fields of type int as well as decimal, as defined in the XSD that the payload is derived from. These fields, part of the payload, are sent in the input to Rules Dictionary using decision service activity from BPEL. In the input to rules, the XML has a couple of fields of type "int" and couple of fields of type "decimal" and the three of them are sent as empty/null. In the output from the rules however, the fields of type "int" have value of zero and fields of type "decimal" do not come out at all, even though they were empty/null and present in the input.

In the below sample, <client:DuplicateMobile/> , <client:DuplicateLan/> and  <client:DuplicateBill/> are sent as null. DuplicateMobile and DuplicateLan are of type "int" and DuplicateBill is of type "decimal". No actions are performed on these fields/facts within the rules. The input and output looks like below:


################################### Input ########################
Facts_To_BPEL_Var

<dsIn>
<part name="payload">
<callFunctionStateless name="Sample1_DecisionService_1">
<parameterList>
<Person>
<client:Name>
<client:firstName>A</client:firstName>
<client:lastName>A</client:lastName>
</client:Name>
<client:address>
<client:lineOne>1</client:lineOne>
<client:lineTwo>2</client:lineTwo>
<client:city>3</client:city>
</client:address>
<client:Phone>
<client:Mobile>4455</client:Mobile>
<client:Lan>4466</client:Lan>
<client:DuplicateMobile/>
<client:DuplicateLan/>
<client:DuplicateBill/>
<client:Bill>500</client:Bill>
</client:Phone>
<client:Status>Open</client:Status>
</Person>
</parameterList>
</callFunctionStateless>
</part>
</dsIn>
################################### End Input ########################

################################### Output ########################
replyOutput

<RulesInput>
<Person>
<Name>
<firstName>A</firstName>
<lastName>A</lastName>
</Name>
<address>
<lineOne>1</lineOne>
<lineTwo>2</lineTwo>
<city>3</city>
</address>
<Phone>
<Mobile>4455</Mobile>
<Lan>4466</Lan>
<Bill>500</Bill>
<DuplicateMobile>0</DuplicateMobile>
<DuplicateLan>0</DuplicateLan>
</Phone>
<Status>Approved</Status>
</Person>
</RulesInput>
################################### End Output ########################


I have raised a Service Request with Oracle and they have confirmed it to be a be a bug (Bug 9794889: BLANK DECIMAL FIELD INPUT TO RULES ENGINE GETS REMOVED). I do not have the resolution yet and I will update as and when I have one. If somebody is facing the same issue, workaround the issue by modifying the output from rules using a XSLT, before it is processes further !

Peace !

Cheers,
-AR

Monday, June 21, 2010

Expose Dictionaries as Composite Service

I had the discussed cases where decision services were exposed as web services, that could be consumed by BPEL or a Java Client. The dictionary itself, can be exposed as a Composite Service by checking the option as shown below, meaning, you do not need a BPEL to invoke the rules and the consumer can directly pass the payload to the decision service/dictionary and get the output.















I worked on such a case, and I had some issues in hitting the Composite Service. Once the project has been developed and deployed, you can use any web service testing tool to test it. I used SoapUI in this case. I imported the WSDL, created a request and hit the web service using the option of "callFunctionStateless" (the SoapUI created two methods - callFunctionStateless and callFunctionStateful). I got an error as below:


<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <env:Fault xmlns:fpre="http://xmlns.oracle.com/bpel/rules">
         <faultcode>fpre:operationErroredFault</faultcode>
         <faultstring/>
         <faultactor/>
         <detail>
            <errorInfo xmlns="http://xmlns.oracle.com/bpel/rules">
               <errorMessage>RulesWithoutBPEL</errorMessage>
            </errorInfo>
         </detail>
      </env:Fault>
   </env:Body>
</env:Envelope>

I then realized that under the soap:Body, there is a method by name <orac:callFunctionStateless name="">. In the attribute, the name of the decision service which has been exposed as web service should be given. It worked after that !


Peace!

Cheers,
-AR

Friday, June 18, 2010

Special Characters like !,@,#,& in Bucket Sets not supported

Its been quite sometime that I had been working on Oracle Business Rules. I noticed that when configuring aliases in the project with the use of bucket sets, few of the characters were not supported in the bucket set. When these characters were used in bucket sets, and when choosing the alias in decision table actions, the alias was not available, but the value of that alias was only available. I have shown the issue below.

However, this should does not stop one from using these characters. The alias may not be available in the decision table actions, but the decision table works alright. Also, this issue is not spotted when we use the bucket set in conditions and we can choose the alias in conditions. So you can go ahead and use it, compromising on the fact that, the alias would not be available in the decision table.

Bucket Set defined:
 









Bucket Set used in Decision Table Actions:











Bucket Set used in Decision Table Conditions:











Note: I had raised an Oracle SR and what is stated above was confirmed in the SR. Have pasted the SR update below:

In a decision table you can use either bucket alias or bucket name . If your alias contains special chars then you must use the bucket name . OR Set the bucket alias to contain only letters and number and there will be no problems at all . This is not yet in any doc - is just the update to the bug that will be merged to official documentation.


Peace !

Cheers,
-AR

Wednesday, June 16, 2010

Decision Table changes become slow with Tree Mode on

I had a post on Tree Mode in OBR recently. I also did notice that the Jdeveloper became slow, sometimes unresponsive to changes being done in the dictionary when the option of Tree Mode was selected in the decision functions, that existed in the dictionary. I was able to work around that problem and I am now doing the below, when working with decision functions that use tree mode:
  1. In the decision function of the decision table, uncheck the option tree mode temporarily
  2. Make the changes in the decision table. The speed with which the changes reflect now will be the same as what it was initially
  3. Make Sure, once the changes are done, the tree mode option is checked in the decision function
Even if you forget to check the option again in the decision table, no worries. Rule engine will not validate the dictionary and would not let the project to be deployed. The reason why the changes become slow when the tree mode is selected is not yet known officially, but my guess is that, the rule engine tries to validate the payload for changes in the tree mode, which means it has to iterate through all the elements. In the other case, the payload and definition must have been cached.

Peace!

Cheers,
-AR

Friday, June 11, 2010

Unable to copy rules within decision table – Table locked error

Decision table is an easy to understand and the best means to depict your conditions when you are validating against many facts and asserting more than fact, as a result. But, if there too many rules that you need to configure, it becomes a mundane task to create rules in a decision table. The simplest way we all know to replicate something is a copy-paste and rules is no different. The decision table has an option "copy" when you right click on a rule. But when try to copy and paste a rule, you get an error:









I had raised a SR with Oracle and I was informed that this option would be removed from Rules UI, in the future releases of OBR.

I found another easier option to replicate rules. For instance, if you have configured a rule asserting/modifying many facts in the actions based on a boolean condition and you would want to replicate the actions for other condition of boolean expression, try selecting both true/false in conditions and then split the cell (right click on condition to find the option "Split Selected Cell"). This will create two rules identical to each other, one for boolean expression true and other, false !

Peace!

Cheers,
-AR

Thursday, June 10, 2010

Tree Mode in Oracle Business Rules 11g

I was struggling sometime last week with an issue in using the "Tree Mode" option in the decision table of a dictionary in Oracle Business Rules 11g (OBR). I selected the tree mode option in the decision table and selected the root for the tree mode also. I configured my decision table as required and that did not have any errors. However, there was some error in dictionary validation like:

RUL-05162: The rule set "ACU" requires fact type "ServiceType", but this type is not part of the input.
TEST/Data Model/Decision Function(TEST_DecisionService_1)
RUL-05162: The rule set "UCS" requires fact type "ServiceType", but this type is not part of the input.
TEST/Data Model/Decision Function(TEST_DecisionService_1)
RUL-05162: The rule set "AMB" requires fact type "ServiceType", but this type is not part of the input.
TEST/Data Model/Decision Function(TEST_DecisionService_1)
RUL-05162: The rule set "ALG" requires fact type "ServiceType", but this type is not part of the input.
TEST/Data Model/Decision Function(TEST_DecisionService_1)
RUL-05164: The fact type "ServiceType" is referenced, but is not asserted nor input.
TEST/Data Model/Decision Function(TEST_DecisionService_1)


Then I found that the tree mode option had to be selected in the decision function also. If a dictionary makes a call to another dictionary which uses the tree mode option, the dictionary that is making the call should also have the tree mode option chosen !

The selection of tree mode option in the decision table is available in OBR Users Guide (section 4.8). However, check the option in the decision function as below:












Peace !

Cheers,
-AR

Saturday, April 24, 2010

Oracle Business Rules 11g - II

Well, as promised, here I am, back with some updates. Oracle Business Rules 11g (OBR) really is an interesting tool to work with. That does not mean I am going to take back my words that the scope of the OBR is limited. Its limited for those who plan to use the OBR more as a tool and for those who want to customize the product OBR, avenues are many and there is no stopping them from improvisations.

Its been a little over a couple of months on OBR now. I have a fairly clear idea on what the OBR should be used for and what it can deliver to you. There situations where OBR can be used are plenty, but there is always the choice that one has to make, whether you really need to use OBR. OBR really should be used where one is not sure about the conditions or touch points and how these touch points would change in the future. A simple case would be, in a telecom sphere, if you would have to choose the sets of commands to be fired at the network layer, you could use OBR to configure the parameters. If there are additional commands that need to be added or removed, it becomes easy in that case. And most importantly, the one who would be configuring plans and commands would be the product manager, who need not be technically proficient in Fusion Middleware and he would ideally be a person with more business knowledge and the use of OBR would make things simpler for him. There are humpteen scenarios which one can think at the wink of an eye.

But, there are scenarios where one cannot decide whether to use OBR or not. In those cases, more than analysing whether OBR is required or not, we would have to look at what the OBR would do. If OBR is used as a processing engine, my instinct tells me, its a strict NO to OBR. If the purpose is more of a simple decision making component with runtime flexibility, no doubt, OBR ! The only reason for NO to OBR in the case where OBR would be a processing engine, would be performance. OBR is bad in peformance when its loaded too much. When there are components like BPEL and Mediator available which are meant to be the processing engines and which deliver excellent performance, it does not justify the need to use OBR in those cases. With this post, I hope I have introduced OBR and would like to get to the technical part of OBR in the posts to come. All said and done, this has not stopped me from ruminating on what I have written above...

Peace !

Cheers,
- AR

Thursday, April 15, 2010

Oracle Business Rules 11g - I

It’s been only 45 days that I had started to work with Oracle Business Rules 11g. I had not worked extensively on Oracle Business Rules 10g, but I knew that it existed and I had done some simple samples. We could not really think of Business Rules handling complexities in 10g. 11g though has been improved and it has a few entities that make Rules 11g interesting to work with. To understand about the Oracle Business Rule 11g, I used the OBR 11h Users Guide available at the Official Site.

It was very interesting to work with Rules in the beginning but, I have to started to get a feeling that scope of OBR is limited and one cannot keep on working on OBR (you do not have much to work for that long). I intended this for people who use OBR as a tool and not for the ones involved in product development. To understand the basics and for access to samples, please visit the Official Site as there are enough materials to get started with.

I will come back with posts on issues, interesting things I found in OBR or if there is something I am still trying to figure out.

Peace !

Cheers,
- AR

Friday, February 26, 2010

AIA 30 - Time for a break !

Yupp, I will have to stop with AIA 30 for the time being. I am starting work on Oracle Business Rules 11g now.

So posts on OBR 11g will also be available on this blog !


Cheers,
- AR
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License