[rules-users] bound variable scope

Esteban Aliverti esteban.aliverti at gmail.com
Wed Nov 6 03:23:39 EST 2013


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?
One possible (of many) solution could be to 'collect' all your events
instead of counting them:

rule "Reset alarm"
when
        a : Alarm()
        c : Set( size > 5) from accumulate (
                e : Event( level < 6) over window:time(10s) from
entry-point "queue",
                collectSet(e)
        )
then
        //All the Event objects matching the LHS are going to be in the set.
        channels["reset"].send("Alarm resolved.");
end


Regards,




XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com


On Tue, Nov 5, 2013 at 11:38 PM, webfrank <webfrank at tiscali.it> wrote:

> Hi,
>    I have a rule with a "from accumulate" where I bind "e" variable to
> Event
> object. I would like to pass "e" to
> send method of channel like: channels["reset"].send(e); but I got a Rule
> Compilation error with: "e cannot be resolved". Why I cannot access
> variable
> "e" when defined inside from accumulate?
>
>
> rule "Reset alarm"
> when
>         a : Alarm()
>         c : Number( intValue > 5) from accumulate (
>                 e : Event( level < 6) over window:time(10s) from
> entry-point "queue",
>                 count(e)
>         )
> then
>         channels["reset"].send("Alarm resolved.");
> end
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/bound-variable-scope-tp4026652.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20131106/77a1c1bb/attachment.html 


More information about the rules-users mailing list