<div>Have you ever tried out to insert the events into the WorkingMemoryEntryPoint &quot;EventStream&quot; directly that you have commented out in your execute method?</div><div>and read the window from that eventstream in your rule, that is, &quot;window:length( 5 ) from entry-point EvenStream&quot;.</div>
<div> </div><div>Of course, the second rule will fire also if it would be no event but a simple fact for drools.</div><div>Unfortunately, I do not know under which condition the default entrypoint is populated.<br><br></div>
<div class="gmail_quote">2012/1/31 juankera <span dir="ltr">&lt;<a href="mailto:juankera@gmail.com">juankera@gmail.com</a>&gt;</span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
Tried, but won&#39;t work.<br>
<br>
Ok, step by step.<br>
<br>
1- DRL File<br>
<br>
Event declared, FirstRule won&#39;t work and SecondRule is working properly<br>
(neither count or sum)<br>
<div class="im"><br>
declare StateEvent<br>
        @role( event )<br>
end<br>
<br>
</div>rule &quot;FirstRule&quot;<br>
<br>
when<br>
        Number( $total : doubleValue ) from accumulate(<br>
        StateEvent(itemName==&quot;Temperatura&quot;, $val : newState) over<br>
window:length( 5 ),<br>
        count ( 1 ))<br>
then<br>
    System.out.println(&quot;&quot; + $total);<br>
end<br>
<br>
rule &quot;SecondRule &quot;<br>
<br>
when<br>
        StateEvent(itemName==&quot;Temperatura&quot;, $val : newState)<br>
then<br>
        System.out.println(&quot;&quot; +<br>
((DecimalType)$val).toBigDecimal().doubleValue());<br>
end<br>
<br>
2. Important lines from Engine starting (notice that i&#39;m using stateful<br>
session)<br>
<br>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
<br>
kbuilder.add(ResourceFactory.newClassPathResource(RULES_CHANGESET,<br>
getClass()), ResourceType.CHANGE_SET);<br>
<br>
KnowledgeBaseConfiguration kbaseConfig =<br>
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();<br>
kbaseConfig.setOption( EventProcessingOption.STREAM );<br>
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);<br>
<br>
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();<br>
<br>
3. Attached you can find the full code<br>
<a href="http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java" target="_blank">http://drools.46999.n3.nabble.com/file/n3703619/RuleService.java</a><br>
RuleService.java<br>
<br>
4. Environment<br>
<br>
Drools 5.3.0 FINAL, running on a OSGi environment.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703619.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-Accumulate-function-events-and-stream-processing-tp3700577p3703619.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------<br>Philipp Herzig, M.Sc.<br><br>Mail: <a href="mailto:pherzig@googlemail.com" target="_blank">pherzig@googlemail.com</a><br>
Cell: 0178 - 6156244<br>