DSL and 5.3 Final
by Rob Fisher
Having the following DSL statement coded:
[condition][]- where {VarName} is {AttributeName} and is {operator}
{value}={VarName}: {AttributeName} {operator} {value}
DSLR looks like this:
ThereIsProgramHistoryData
- where $var01 is LevelPriorYear and is greater than 0
DSL parses to this:
ProgramHistory ($var01: levelPy > 0)
Parsed just fine in 5.2 Final. Downloaded 5.3 today but am now getting
following error for every rule that uses the above DSL:
"no viable alternative at input ','"
The DRL looks like this : ProgramHistory ( , $var01: levelPy > 0)
What changed in 5.3 that is causing the comma to be inserted?
Any help is much appreciated!
--
View this message in context: http://drools.46999.n3.nabble.com/DSL-and-5-3-Final-tp3869806p3869806.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
Re: [rules-users] Rule does not work without another rule testing eval(true)
by David Bennison
In the words of the great Homer... "Doh!"
Thanks for your help Wolfgang.
Dave
</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>
13 years, 11 months
Rule does not work without another rule testing eval(true)
by David Bennison
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>
13 years, 11 months
Drools-Fusion: Problem with loading data
by Luciano Molinari
Hi guys,
I'm trying drools-fusion's cep capabilities but I'm having some troubles on
loading the data to the Working Memory. I have three types defined in the
DRL File: Customer, POS (Point of sale) and Transaction (event). I have a
rule to discover suspicious transactions (customers that have made two
transactions in ten seconds and from diferents POS).
Besides, I have other 3 helper rules that receive the fact (Customer or
POS) or the event (Transaction) in JSON format, convert it and store it in
the session (Customer or POS) or forward the event to another entry-point.
My drools file:
global org.codehaus.jackson.map.ObjectMapper jsonConverter;
declare Event
@role(event)
id : String
logicNumber : String
customer : String
end
declare POS
logicNumber : String
end
declare Customer
id : String
end
rule "rule_convertAndInsertPOS"
when
$json : String() from entry-point convertAndInsertPOS
then
POS pos = jsonConverter.readValue($json, POS.class);
retract($json);
insert(pos);
end
rule "rule_convertAndInsertCustomer"
when
$json : String() from entry-point convertAndInsertCustomer
then
Customer customer = jsonConverter.readValue($json, Customer.class);
retract($json);
insert(customer);
end
rule "rule_convertAndSendEvent"
when
$json : String() from entry-point convertAndSendTransaction
then
Event evt = jsonConverter.readValue($json, Event.class);
System.out.println("Repassando evento " + evt);
entryPoints["StreamTransactions"].insert(evt);
retract($json);
end
rule "rule_suspiciousTransactionInDifferentsPOSOfSameCustomer"
dialect "mvel"
when
$pos : POS($posNumber : logicNumber)
$customer : Customer($idCustomer : id)
$trans1 : Event(logicNumber == $posNumber, customer == $idCustomer)
from entry-point StreamTransactions
$trans2 : Event(logicNumber != $posNumber, customer == $idCustomer,
this after[0, 10s] $trans1) from entry-point StreamTransactions
then
System.out.println("Suspect fraud between the transactions " + $
trans1.id + " and " + $trans2.id);
end
In my test case, before starting sending events to the entry-point
"convertAndSendTransaction", I try to load some POS and Customers.
private void loadPOS() {
WorkingMemoryEntryPoint entryPointConvertAndInsertPOS = kSession
.getWorkingMemoryEntryPoint("convertAndInsertPOS");
log("Loading POS");
for (int i = 1; i <= 20000; i++) {
if ((i % 1000) == 0) {
log("Inserting POST " + i);
kSession.fireAllRules();
}
entryPointConvertAndInsertPOS.insert(getPOSInJson("POS" + i));
}
kSession.fireAllRules();
log("POS loaded");
}
private void loadCustomer() {
WorkingMemoryEntryPoint entryPointConvertAndInsertCustomer =
kSession
.getWorkingMemoryEntryPoint("convertAndInsertCustomer");
for (int i = 1; i <= 10000; i++) {
if ((i % 1000) == 0) {
log("Inserting customer " + i);
kSession.fireAllRules();
}
entryPointConvertAndInsertCustomer.insert(getCustomerInJson(String.valueOf(i)));
}
kSession.fireAllRules();
log("Customers loadaed");
}
No matter if I call loadPOS() or loadCustomer() first, the first one I call
is executed correctly, but when I call the second one it stops on
fireAllRules() and the memory increases untill OME.If I remove the rule
"rule_suspiciousTransactionInDifferentsPOSOfSameCustomer" from the DRL
file, both the loading executes correctly. It seems that the when the data
is inserted into the session, the begin of this rule is being executed or
something like that.
How can I solve this issue?Is there any way of just executing the rules of
loading data at this moment?Is there a better way to achieve what I'm
trying?
The full project (maven) is attached to this email.
Thanks and sorry for the English.
--
Luciano Davoglio Molinari
http://lucianomolinari.wordpress.com/
13 years, 11 months
Re: [rules-users] Having problems with traits in 5.4.0beta2
by Greg Barton
It's not, but can easily be. I just tried that, though, and the same exception happened.
DRL attached. It's an old attempt to update the classic monkeys and bananas example to make it a bit more interesting: wandering monkeys, stacking blocks, a bit of world physics, stuff like that. I haven't touched it for several years and wanted to update it with new drools features for a presentation I'm doing on Tuesday. I was able to use the new parser features to eliminate a ton of evals, and would like to put traits and propSpecific features in.
And just to confuse things a bit I have a question about propSpecific. :) Is it possible to annotate a method to indicate that it changes properties on a different object type other than itself? Take the "monkey_finds_block" rule as an example. The Monkey.setHolding() method modifies the thing that's being held. It would be great if I could annotate Monkey.setHolding() to indicate that it not only modifies Monkey.holding, but also Entity.location and Entity.holds.
--- On Sun, 3/11/12, Davide Sottara <dsotty(a)gmail.com> wrote:
> From: Davide Sottara <dsotty(a)gmail.com>
> Subject: Re: [rules-users] Having problems with traits in 5.4.0beta2
> To: rules-users(a)lists.jboss.org
> Date: Sunday, March 11, 2012, 11:58 AM
> Is HungryMoneky an interface you have
> outside the DRL?
> Can you send me the full DRL anyway?
> Thanks
> Davide
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/rules-users-Having-problems-with-traits...
> Sent from the Drools: User forum mailing list archive at
> Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
13 years, 11 months
Clarification of how the Persistence Manager works
by Akinmolasire, Denis
Hello All
I understand that Guvnor uses the PersistenceManager in JackRabbit to persist data but I would like confirmation of how it works. Namely the following.
* What actions cause the PersistenceManager to persist data?
* When a back end java process connects to the Guvnor server in terms of accessing the Knowledgebase is it through a Cache or direct database connection?
* If a user updates the knowledge is it real time update or does the user need to click on Save and validate to persist the change.
Thanks
Denis A
13 years, 11 months
NPE from LHS of rule is not returned by Drools to calling program
by scottleff
During development of our Drools rule base I had a case where a rule compiled
fine, but at runtime a NPE is thrown by MVEL when applying the predicate
(LHS) because the Coverage.vehicleSupplement attribute was NULL. I had
expected the NPE to be returned to my calling java program so that my
try/catch could address the issue. However, the exception was sent to
System.err and the rule was simply skipped. First, is the the default
behavior in Drools for Exceptions thrown from the LHS? If so, can it be
overridden to actually return the exception?
rule "BR--UM Stacked Coverage"
agenda-group "BR_Change"
dialect "mvel"
when
coverage : Coverage( vehicleSupplement.stackable == true , coverageCode ==
"UDCSL")
vehicle : Vehicle( unitAtRiskNumber : unitAtRiskNumber)
Policy( state == "NM" )
then
WorkItemReason fact0 = new WorkItemReason();
fact0.setType( "Policy" );
fact0.setReason( "6408: UM/UDM stacking change" );
fact0.setAddBookmark( "VE" );
fact0.setAddBookmarkUnit( unitAtRiskNumber );
insertLogical(fact0 );
end
*Here is the stacktrace from my console:*
WARNING: java.lang.RuntimeException: cannot invoke getter:
getVehicleSupplement [declr.class: com.fbfs.pc.ecd.model.Coverage;
act.class: com.fbfs.pc.ecd.model.Coverage] (see trace)
at
org.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:74)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:106)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:87)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:122)
at org.mvel2.MVEL.executeExpression(MVEL.java:954)
at
org.drools.base.extractors.MVELClassFieldReader.getValue(MVELClassFieldReader.java:100)
at
org.drools.base.extractors.BaseObjectClassFieldReader.isNullValue(BaseObjectClassFieldReader.java:179)
at
org.drools.base.evaluators.EqualityEvaluatorsDefinition$BooleanEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:555)
at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)
at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:174)
at
PolicyDefinitionRules.Rule_policyDefinition_UnitAtRiskCoverage.defaultConsequence(Rule_policyDefinition_UnitAtRiskCoverage.java:8)
at
PolicyDefinitionRules.Rule_policyDefinition_UnitAtRiskCoverageDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:708)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:672)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at
com.fbfs.pc.rulesengine.controller.RulesEngine.runRulesEngine(RulesEngine.java:318)
My expectation that Exceptions thrown from the consequence (RHS) are
returned to the calling program was confirmed when I added the following 2
lines to a rule that was not experiencing the above issue:
String myString = null;
System.out.println(myString.trim());
Is there any good documentation on Drools exception handling?
Current configuration is Drools 5.3.0, MVEL 2.1.0, Glassfish 2.1
--
View this message in context: http://drools.46999.n3.nabble.com/NPE-from-LHS-of-rule-is-not-returned-by...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
[drools-spring]Incompatibility with jdk 5
by jsoula
Hello,
I'm using drools-spring version 5.3.0.Final, jdk 5.
During execution, i have this error:
Caused by: java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
at
org.drools.container.spring.namespace.ResourceDefinitionParser.parseInternal(ResourceDefinitionParser.java:89).
Indeed the class ResourceDefinitionParser use String.empty. This is an
upgrade from 5.2.1.Final.
Is it a bug? Or is the compatibity with jdk5 no more maintained?
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/drools-spring-Incompatibility-with-jdk-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
Multi-function Accumulates
by Hassan
Hello everybody
I don't know why the Multi-function Accumulates doesn't work,
I m just copying the code given in he documentation
rule "Max, min and average"
when
accumulate( Cheese( $price : price ),
$max : max( $price ),
$min : min( $price ),
$avg : average( $price ) )
then
System.out.println($max+" "+$min+" "+$avg);
end
But it gives me some problems !!
-----
Youssef AZBAKH.
--
View this message in context: http://drools.46999.n3.nabble.com/Multi-function-Accumulates-tp3867251p38...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months