Bug 1017095 - A rule condition is not performed when a fact is updated
Summary: A rule condition is not performed when a fact is updated
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER5
: 6.0.0
Assignee: Maciej Swiderski
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-09 09:13 UTC by Ivo Bek
Modified: 2014-08-06 20:13 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:13:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
process definition with the intermediate catch event (6.69 KB, application/xml)
2013-10-09 09:13 UTC, Ivo Bek
no flags Details

Description Ivo Bek 2013-10-09 09:13:52 UTC
Created attachment 809799 [details]
process definition with the intermediate catch event

Description of problem:

I have an intermediate catch event containg:

p: org.kie.api.runtime.process.WorkflowProcessInstance()
personId: Integer() from p.getVariable("personId")
org.jboss.qa.brms.domain.Person(id == personId, name == "John")

when the name of person is changed to "John" and updated in session, nothing will happen and the process won't proceed further.

The update is done the same way as it was in jbpm5, it means:

FactHandle personHandle1 = ksession.insert(person1);
// start process instance
// update person1
ksession.update(personHandle1, person1);

There was a similar issue (https://issues.jboss.org/browse/JBPM-3626) in jbpm5 that the name of workflow process instance couldn't be other than processInstance but it's NOT this case because I have tried it.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Kris Verlaenen 2013-10-09 11:16:07 UTC
Ivo, are you also inserting the process instance itself into the ksession after starting it?

Comment 2 Ivo Bek 2013-10-09 11:49:12 UTC
yes, sure I add the process instance too. Here is the whole java code http://pastebin.com/78GUmkDi

Comment 3 Ivo Bek 2013-10-09 11:53:12 UTC
I was too hurry, the issue is with the first process http://pastebin.com/YnGmLSKY

Comment 4 Maciej Swiderski 2013-10-09 13:46:35 UTC
the behavior has changed in the way how rules are activated. In v6 drools uses lazy activation and thus fireAllRules must be invoked to trigger the evaluation. In comparison to v5 where activation happened on insert/update/retract.
That means that whenever conditional events are used fireAllRules must be used to properly trigger rules after facts were inserted/update/retracted.

So I believe this is not a bug but expected behavior which requires most likely documentation update that rule engine uses lazy activation and requires fireAllRules to be invoked.

Comment 5 Kris Verlaenen 2013-10-14 12:46:47 UTC
Maciej, rules could also be defined as @eager (see for example https://github.com/droolsjbpm/jbpm/blob/master/jbpm-flow-builder/src/main/java/org/jbpm/compiler/ProcessBuilderImpl.java#L408) to avoid this.

It seems most of the generated rules use this, although gateway constraints and start event constraints don't seem to have that annotation yet.  So I believe adding that annotation there as well would make sense and solve this issue.

Comment 6 Maciej Swiderski 2013-10-15 06:50:53 UTC
Kris, I am aware of this but unfortunately it does not mean the rule will be activated on insert/update/retract basis and thus fireAllRules is still mandatory to get that working. I double checked that with drools team and the @Eager places rules only on top of the processing queue. There are some discussion on how that might be supported on drools side but currently there is no way to activate the rule without fireAllRules.

Comment 7 Maciej Swiderski 2013-10-21 10:58:46 UTC
Based on modifications applied on drools side now we can configure ksession to activate rules that are marked as @Eager on insert/update/retract basis. Configuration by default is done for RuntimeManager:

config.setOption(ForceEagerActivationOption.YES);

where config is KieSessionConfiguration

jbpm
master:
https://github.com/droolsjbpm/jbpm/commit/b1c09c26c03d6e0523beb4abf40dbd8e7efa2250
https://github.com/droolsjbpm/jbpm/commit/f644b7565f7f28f7d68fc6ec11a28ae6863be58a

6.0.x
https://github.com/droolsjbpm/jbpm/commit/0720077005125d8d141210197869864dbcbfe322
https://github.com/droolsjbpm/jbpm/commit/5c580eeca837758541124972d735c0b20d6b4fef

Comment 8 Ivo Bek 2013-12-09 09:54:17 UTC
Verified in BPMS 6.0.0.ER5.

Seems, ForceEagerActivationOption is set by default because I didn't have to change anything. I just removed the fireAllRules method for the test with rules condition.


Note You need to log in before you can comment on or make changes to this bug.