[rules-users] Multiple bindings with the same type
Greg Barton
greg_barton at yahoo.com
Wed Dec 8 16:59:35 EST 2010
Still won't work, and it's worse than you think. The main problem is that drools (and any rules engine) will match on all possible combinations of objects in working memory that match the right hand side of the rule. So let's say you insert two lists, call them A and B. Your rule will fire four times on AxB, BxA, AxA, and BxB. You have to make sure you don't match the same object twice, and even then you must have an explicit test for ordering. For this reason it's best to match on a custom object (not just java.util.ArrayList) that contains data you can test for ordering.
GreG
On Dec 8, 2010, at 14:19, Gabor Szokoli <szocske at gmail.com> wrote:
> Hi,
>
> 2010/12/8 Robert Miyashiro <robert at mercedsystems.com>:
>> Is there some kind of evaluation mode or setting that will make
>> Drools pay attention to the order in which objects are inserted into the
>> session?
>
> Not that I know of, but here's a way to externally supply the pairs of
> objects to fire on:
>
> rule
> when
> $list1 : ArrayList()
> $list2 : ArrayList()
> Pair(first==$list1, second==$list2)
> then
>
> If you find yourself reasoning about the order and timing of insertion
> events, you may want to look into drools fusion instead.
>
>
> Gabor
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list