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

Philipp Herzig pherzig at googlemail.com
Tue Jan 31 10:52:49 EST 2012


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 at 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-and-stream-processing-tp3700577p3703619.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
--------------------------------------------
Philipp Herzig, M.Sc.

Mail: pherzig at googlemail.com
Cell: 0178 - 6156244
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120131/da983bd7/attachment.html 


More information about the rules-users mailing list