Hi All,

I am using Drools Stateful session with serialized Rule Base & Working
memory for my application. I need to write some rule which will *only* fire
on newly inserted data points in Working Memory. Does Drools support any
such feature which will help me to achieve this ? Any suggestion, how can I
achieve this efficiently?


As sample, I have written a rule bellow:

global RuleSetOutput ruleSetOutput
 rule "sample_rule"
 when
          (p4: DataObject(id == 4, stringValue == "230007014")) and
          (p14: DataObject(id == 14, stringValue == "230007004")) and
          (p10: DataObject(id == 10, stringValue == "230007005")) and
          (p11: DataObject(id == 11, stringValue == "230007006")) and
          (p12: DataObject(id == 12, stringValue == "230007007")) and
          (p13: DataObject(id == 13, stringValue == "230007008"))
 then
          String ruleID = "sample_rule";
          RuleOutput ruleOutput =
RuleEngineHelper.getRuleOutput(ruleSetOutput, ruleID);
          ruleOutput.addDataObject(p13);
          ruleOutput.addDataObject(p4);
          ruleOutput.addDataObject(p11);
          ruleOutput.addDataObject(p14);
          ruleOutput.addDataObject(p10);
          ruleOutput.addDataObject(p12);
end

For 1st execution, I am inserting 6 matching DataObjects into Working
Memory. Rule is getting fired once & those 6 data points are getting added
into RuleOutput.

But in subsequent rule executions after I insert 6 more matching DataObjects
into Working Memory, Rule is getting fired couple of times  & objects from
old executions also getting appended to the current RuleOutput.

How can I avoid this ?

Regards
Siddhartha
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to