[rules-users] need design suggestion

Wolfgang Laun wolfgang.laun at gmail.com
Wed Apr 4 07:22:07 EDT 2012


On 03/04/2012, Joe Zendle <jzendle at gmail.com> wrote:
> Wolfgang, thanks much. Helps me understand what's going on under the hood a
> little better.
>
> I'm having a similar issue with the next higher container. I have say,
> PathElements which contain a collection of Ports. Same problem as before -
> if one Port goes down then the PathElement goes down. I can't seem to
> express it properly in DRL
>
> The only thing that comes to me is:
>
> rule "pe down"
>     when
>         // pe is active
>      $pe : PathElement(state == State.UP )
>     // and any one of the ports are down
>     Port ( state == State.DOWN ) from $pe.ports
>     then
>     System.out.println("  setting pe down"  + $pe );
>     modify($pe) {
>     setState( State.DOWN);
>     }
> end
>
> However, like my other naive attempts, it is not firing after the
> Notification is inserted into WM. I tried many variations using a 'collect'
> clause, etc to no avail. Any additional insight would be greatly
> appreciated.

Forget from when you have all relevant objects as facts in WM.

Rule "pe down" is evaluated while all the Ports are still OK, and so
nothing happens. When the Port is set DOWN, there's no reason for
Drools to re-evaluate this rule.

Reevaluation of  patterns in front of "from" is not triggered by
updates of facts with the same type. Only an update of a PathElement
would do this.

-W



More information about the rules-users mailing list