<div dir="ltr">Variable e scope is the accumulate. You can't use it outside. But think about it for a second, when your rule is activated, variable e (if it would be possible to access it from the RHS) will have at least 6 different values. Which value do you want to use?<div>
One possible (of many) solution could be to 'collect' all your events instead of counting them:</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">rule "Reset alarm"</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">when</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> a : Alarm()</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> c : Set( size > 5) from accumulate (</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> e : Event( level < 6) over window:time(10s) from entry-point "queue",</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> collectSet(e)</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> )</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">then</span></div><div> //All the Event objects matching the LHS are going to be in the set.<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> channels["reset"].send("Alarm resolved.");</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">end</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Regards,</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><br></div></div><div class="gmail_extra">
<br clear="all"><div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a></div>
<br><br><div class="gmail_quote">On Tue, Nov 5, 2013 at 11:38 PM, webfrank <span dir="ltr"><<a href="mailto:webfrank@tiscali.it" target="_blank">webfrank@tiscali.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
I have a rule with a "from accumulate" where I bind "e" variable to Event<br>
object. I would like to pass "e" to<br>
send method of channel like: channels["reset"].send(e); but I got a Rule<br>
Compilation error with: "e cannot be resolved". Why I cannot access variable<br>
"e" when defined inside from accumulate?<br>
<br>
<br>
rule "Reset alarm"<br>
when<br>
a : Alarm()<br>
c : Number( intValue > 5) from accumulate (<br>
e : Event( level < 6) over window:time(10s) from entry-point "queue",<br>
count(e)<br>
)<br>
then<br>
channels["reset"].send("Alarm resolved.");<br>
end<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/bound-variable-scope-tp4026652.html" target="_blank">http://drools.46999.n3.nabble.com/bound-variable-scope-tp4026652.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<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>
</blockquote></div><br></div>