You start your process and it rips quickly through all rule flows.
Then you insert a fact, which would trigger something in the rule flow
group - but this one's history.
In the second scenario, the additional rule creates an activation
without requiring an facts, and this activation works just like a
sluice gate, barring progress, so that your insertions can throw some
facts into the eddying waters...
I hope this wasn't too poetic ;-)
-W
On 30/03/2012, David Bennison <David.Bennison(a)cdl.co.uk> wrote:
Hi,
I have a simple rule (for a JUnit test) in a single ruleflow group, as
configured in the BPNM:-
<process processType="Private" isExecutable="true"
id="liveDateStart"
name="liveDateStart"
tns:packageName="co.uk.cdl.vis.miami.rules.miamicontext" >
<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<businessRuleTask id="_3" name="goLiveDateCheck"
g:ruleFlowGroup="goLiveDateCheck" >
</businessRuleTask>
<endEvent id="_4" name="EndProcess" >
<terminateEventDefinition/>
</endEvent>
<!-- connections -->
<sequenceFlow id="_1-_3" sourceRef="_1"
targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3"
targetRef="_4" />
</process>
When I run the rule it appears to enter the LHS but never RHS (unless I
replace the LHS with eval(true)), even though the MiamiContext Fact is
present and correct.
However, if I add another rule in the rule file that simply contains
eval(true) in the LHS (and debug in the RHS), then my original rule
fires correctly.
This can't be correct but I cannot find a way to get it to work without
the second rule.
Rules configured in other .drl files and ruleflows are working correctly
(using the same Java code etc), so there must be something particular to
this rule that is wrong ... but I can't see what!
Any help would be much appreciated.
I am using Drools 5.3.0
package uk.co.cdl.vis.miami.rules.miamicontext;
import uk.co.cdl.vis.miami.rules.RulesLogger;
import uk.co.cdl.vis.miami.model.MiamiContext;
import org.joda.time.DateTime;
dialect "mvel"
## Go-Live Date
########################################################################
#################
rule "Increment GoLiveDate"
ruleflow-group "goLiveDateCheck"
when
$miamiContext : MiamiContext($date : goLiveDate )
then
RulesLogger.LOG.debug("*********** BEFORE:" +
$miamiContext.goLiveDate);
$miamiContext.goLiveDate = $date.plusDays(1);
RulesLogger.LOG.debug("*********** AFTER:" +
$miamiContext.goLiveDate);
end
## Without this rule the above rule does not work
rule "goLiveDateTEST"
ruleflow-group "goLiveDateCheck"
when
eval(true)
then
RulesLogger.LOG.debug("*********** goLiveDateTEST ***********");
end
The knowledge engine is run as follows and the startProcess is
"liveDateStart":-
public Collection<Object> executeRules(Collection<Object> facts) throws
Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(changeSet),
ResourceType.CHANGE_SET);
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
new Slf4jWorkingMemoryLogger(ksession);
if (StringUtils.isNotBlank(startProcess)) {
ksession.startProcess(startProcess);
}
for (Object fact : facts) {
ksession.insert(fact);
}
ksession.fireAllRules(MAX_RULE_FIRES);
Collection<Object> resultFacts = ksession.getObjects();
ksession.dispose();
return resultFacts;
}
Log without 2nd rule :-
2012-03-30 12:17:03,567 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW STARTED
process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,576 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,576 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,577 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,580 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW GROUP ACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 12:17:03,580 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW GROUP ACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 12:17:03,580 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,580 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,581 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,581 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW STARTED
process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,583 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW GROUP DEACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 12:17:03,584 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW GROUP DEACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 12:17:03,584 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,584 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,585 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,585 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW COMPLETED
process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,585 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW COMPLETED
process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,586 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,586 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,586 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 12:17:03,601 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) ACTIVATION CREATED rule:Increment
GoLiveDate activationId:Increment GoLiveDate [1] declarations:
$date=2012-03-02T10:21:05.000Z(1);
$miamiContext=MiamiContext[goLiveDate=2012-03-02T10:21:05.000Z](1)
ruleflow-group: goLiveDateCheck
2012-03-30 12:17:03,602 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) OBJECT ASSERTED
value:MiamiContext[goLiveDate=2012-03-02T10:21:05.000Z] factId: 1
Log with 2nd rule:-
2012-03-30 11:59:16,657 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) ACTIVATION CREATED
rule:goLiveDateTEST activationId:goLiveDateTEST [0] declarations:
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,670 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW STARTED
process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,677 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,678 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,679 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,680 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW GROUP ACTIVATED
group:goLiveDateCheck[size=1]
2012-03-30 11:59:16,681 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW GROUP ACTIVATED
group:goLiveDateCheck[size=1]
2012-03-30 11:59:16,681 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,681 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,681 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:StartProcess[id=1] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,681 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW STARTED
process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,699 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) ACTIVATION CREATED rule:Increment
GoLiveDate activationId:Increment GoLiveDate [1] declarations:
$date=2012-03-02T10:21:05.000Z(1);
$miamiContext=MiamiContext[goLiveDate=2012-03-02T10:21:05.000Z](1)
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,700 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) OBJECT ASSERTED
value:MiamiContext[goLiveDate=2012-03-02T10:21:05.000Z] factId: 1
2012-03-30 11:59:16,701 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE ACTIVATION FIRED
rule:Increment GoLiveDate activationId:Increment GoLiveDate [1]
declarations: $date=2012-03-02T10:21:05.000Z(1);
$miamiContext=MiamiContext[goLiveDate=2012-03-02T10:21:05.000Z](1)
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,707 DEBUG [main]
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ***********
BEFORE:2012-03-02T10:21:05.000Z
2012-03-30 11:59:16,709 DEBUG [main]
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ***********
AFTER:2012-03-03T10:21:05.000Z
2012-03-30 11:59:16,710 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER ACTIVATION FIRED
rule:Increment GoLiveDate activationId:Increment GoLiveDate [1]
declarations: $date=2012-03-03T10:21:05.000Z(1);
$miamiContext=MiamiContext[goLiveDate=2012-03-03T10:21:05.000Z](1)
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,710 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE ACTIVATION FIRED
rule:goLiveDateTEST activationId:goLiveDateTEST [0] declarations:
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,710 DEBUG [main]
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ***********
goLiveDateTEST ***********
2012-03-30 11:59:16,711 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER ACTIVATION FIRED
rule:goLiveDateTEST activationId:goLiveDateTEST [0] declarations:
ruleflow-group: goLiveDateCheck
2012-03-30 11:59:16,711 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW GROUP DEACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 11:59:16,712 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW GROUP DEACTIVATED
group:goLiveDateCheck[size=0]
2012-03-30 11:59:16,714 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,714 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,714 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE PROCESS NODE EXITED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,715 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) BEFORE RULEFLOW COMPLETED
process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,715 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER RULEFLOW COMPLETED
process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,715 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,716 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:EndProcess[id=4] process:liveDateStart[id=liveDateStart]
2012-03-30 11:59:16,716 DEBUG [main]
uk.co.cdl.vis.miami.engine.rules.Slf4jWorkingMemoryLogger.logEventCreate
d(Slf4jWorkingMemoryLogger.java:23) AFTER PROCESS NODE TRIGGERED
node:goLiveDateCheck[id=3] process:liveDateStart[id=liveDateStart]
</PRE>
<p style="font-family:'Arial';font-size:8pt">
**********************************************************************<br>
Please consider the environment - do you really need to print this
email?<br>
<br>
This email is intended only for the person(s) named above and may contain
private and confidential information. If it has come to you in error, please
destroy and permanently delete any copy in your possession and contact us on
+44 (0) 161 480 4420. The information in this email is copyright © CDL
Group Holdings Limited. We cannot accept any liability for any loss or
damage sustained as a result of software viruses. It is your responsibility
to carry out such virus checking as is necessary before opening any
attachment.<br>
Cheshire Datasystems Limited uses software which automatically screens
incoming emails for inappropriate content and attachments. If the software
identifies such content or attachment, the email will be forwarded to our
Technology Department for checking. You should be aware that any email which
you send to Cheshire Datasystems Limited is subject to this procedure. <br>
Cheshire Datasystems Limited, Strata House, Kings Reach Road, Stockport SK4
2HD<br>
Registered in England and Wales with Company Number 3991057<br>
VAT registration: 727 1188 33</p>
<PRE>