Jaroslaw,
This looks like a bug. Would you please open a JIRA and attach the
info bellow as well as drools and mvel version used?
Thanks,
Edson
2009/6/30 Jaroslaw Kijanowski <kijanowski(a)gmail.com
<mailto:kijanowski@gmail.com>>
Hi,
I'm using sliding windows (hence stream mode).
Here's my rule:
declare Sensor
@role (event)
end
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 {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("cep.drl"),
ResourceType.DRL);
if (kbuilder.getErrors().size() > 0) {
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBaseConfiguration kbaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbaseConfig.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
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
+++++++++++++++
Thanks,
Jarek
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org <mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com <
http://www.jboss.com>
------------------------------------------------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users