[jboss-jira] [JBoss JIRA] Created: (JBRULES-2150) stream mode requires DroolsStreamUtils
Jaroslaw Kijanowski (JIRA)
jira-events at lists.jboss.org
Tue Jun 30 11:05:08 EDT 2009
stream mode requires DroolsStreamUtils
--------------------------------------
Key: JBRULES-2150
URL: https://jira.jboss.org/jira/browse/JBRULES-2150
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core (fusion)
Affects Versions: 5.0.1.FINAL
Reporter: Jaroslaw Kijanowski
Assignee: Edson Tirelli
Attachments: cep.drl, CEPTest.java, Sensor.java
I'm using sliding windows (hence stream mode).
Here's my rule:
rule 'r'
when
Number( dv:doubleValue > 1 ) from accumulate(
Sensor( $v : value ) over window:length( 2 ),
average( $v ) )
then
System.out.println(dv);
end
Here's my class:
++++++++++++++++++++++++++++++++++++++++++++++
public class CEPTest {
public static void main(String[] args) throws Exception {
.
.
.
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeBase kbase2 = (KnowledgeBase) DroolsStreamUtils.streamIn(DroolsStreamUtils.streamOut(kbase), null);
final StatefulKnowledgeSession ksession = kbase2.newStatefulKnowledgeSession();
System.out.println("T1");
ksession.insert(new Sensor(1.0));
ksession.fireAllRules();
System.out.println("T2");
ksession.insert(new Sensor(2.0));
ksession.fireAllRules();
System.out.println("T3");
ksession.insert(new Sensor(3.0));
ksession.fireAllRules();
ksession.dispose();
}
}
++++++++++++++++++++++++++++++++++++++++++++++
The output is (as expected):
+++++++++++++++
T1
T2
1.5
T3
2.5
+++++++++++++++
I'm wondering why I have to use DroolsStreamUtils to get a knowledge base? When I use kbase (which didn't went through DroolsStreamUtils) instead of kbase2 to create a new session, the output will be:
+++++++++++++++
T1
T2
2.0
T3
3.0
+++++++++++++++
Attaching all 3 files needed to reproduce - rule, model and test.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list