Memory Management in IBM ODM. Issues with response object creation in IBM Operational decision Manager

453 Views Asked by At

I would like to know, how should we execute the rules written in IBM ODM. I am using ODM V8.0.1. I have tried as below.

I created a XOM having a Request class with String variable and Response class with a boolean

public class Request{ private String xyz;
public Request(String s1){
this.xyz=s1;
}//to set DVS
with getters & setters
}

public class Response{
private boolean x; and getters and setters
}

I created a rule project adding this XOM to create respective BOM.

I have added Request Object as IN ruleset parameter and response a OUT Then created a Rule with below code

if xyz of 'the request' is one of {" "," " "," "}

then

set x to true on 'the request';

Created a ruleflow having a action function() and one rule package

I have created

prepareWorkMemory(){
Request r=new Request();
r.x=true;
insert(r);
}

I have generated a DVS excel file and populated the input and expected result.

Then I ran this ruleflow with excel sheet

Run as --> Run Configuration

My execution threw a Nullpointer exception and some other ExecutionUnit exceptions. When I debugged I see that the issue was the response object was not created after the prepWorkingMemory() funtion and when the rule tried to set the boolean value.

I tried setting up the Ruleset parameter as IN_OUT then the execution created the response object for itself without the prepWorkingMemory() function. But it was expecting even the boolean as input which is not right for my scenario.

Can someone please help me with where I went wrong I strongly believe that the issue is with function. Please correct me.

Also if possible can you elaborate on Memory Management in IBM ODM.

Thank you. Your help and time is greatly appreciated :)

1

There are 1 best solutions below

0
On

If you are using Classic Rule Engine, you actually don't need to write preWorkMem kind of function. If direction of your Ruleset Param is IN_OUT, you are not required to create two XOM classes as you have done i.e. Request and Response. You would be using the same object of XOM class in rule conditions and actions.

However, didn't you noticed that you have created two XOM classes namely Request & Response and you are using IN_OUT ruleset param direction? How and Why?

Another catch is in you prepareWorkMemory() function. You are creating object of Request and setting value of 'x' which is actually member of Response class.

Read my first paragraph which will help you write a simple ruleset with single parameter set as IN_OUT. We don't need to enter object in working memory manually unless doing something uncommon.

Should you need any help, please comment on the answer. HAPPY RULE DEVELOPMENT. :)