Have you ever tried out to insert the events into the
WorkingMemoryEntryPoint "EventStream" directly that you have commented out
in your execute method?
and read the window from that eventstream in your rule, that is,
"window:length( 5 ) from entry-point EvenStream".
Of course, the second rule will fire also if it would be no event but a
simple fact for drools.
Unfortunately, I do not know under which condition the default entrypoint
is populated.
2012/1/31 juankera <juankera(a)gmail.com>
Tried, but won't work.
Ok, step by step.
1- DRL File
Event declared, FirstRule won't work and SecondRule is working properly
(neither count or sum)
declare StateEvent
@role( event )
end
rule "FirstRule"
when
Number( $total : doubleValue ) from accumulate(
StateEvent(itemName=="Temperatura", $val : newState) over
window:length( 5 ),
count ( 1 ))
then
System.out.println("" + $total);
end
rule "SecondRule "
when
StateEvent(itemName=="Temperatura", $val : newState)
then
System.out.println("" +
((DecimalType)$val).toBigDecimal().doubleValue());
end
2. Important lines from Engine starting (notice that i'm using stateful
session)
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(RULES_CHANGESET,
getClass()), ResourceType.CHANGE_SET);
KnowledgeBaseConfiguration kbaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbaseConfig.setOption( EventProcessingOption.STREAM );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
3. Attached you can find the full code
http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java
RuleService.java
4. Environment
Drools 5.3.0 FINAL, running on a OSGi environment.
--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-...
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
--
--------------------------------------------
Philipp Herzig, M.Sc.
Mail: pherzig(a)googlemail.com
Cell: 0178 - 6156244