[rules-users] Accumulate function, events and stream processing

juankera juankera at gmail.com
Tue Jan 31 10:11:39 EST 2012


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-and-stream-processing-tp3700577p3703619.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list