[rules-users] About fusion and collections
Amit Kumar
amitkumar at gmail.com
Mon Mar 15 12:33:45 EDT 2010
Kewl !.. sounds good. Thanks for your help folks. I will try the options
out.
2010/3/15 Edson Tirelli <ed.tirelli at gmail.com>
>
> Amit,
>
> Check fireUntilHalt() docs in order to set the engine to reactive
> mode... although, for most cases I've seen, you still have more control by
> defining the fireAllRules() cycle explicitly.
>
> Regarding your rule, the problem is that the first type is matched for
> multiple events. The simplest way to fix that is by pre-populating the
> working memory with all possible event types. In this case you would use a
> rule like:
>
> when
> EventType( $type : type )
>
> $events: ArrayList (size > 10)
> from collect (Event(eventType == $type))
> then
> // do something
> end
>
> You can also find the distinct event types using accumulate, but that is
> heavier and more complex than the previous example. Lets say event type is a
> String:
>
> when
> $types : Set()
> from accumulate( Event($type : eventType),
> collectSet( $type ) )
> $type : String() from $types
>
> $events: ArrayList (size > 10)
> from collect (Event(eventType == $type))
> then
> // do something
> end
>
> I don't really recommend the second approach though. An intermediate
> approach is to have a separate rule logically insert all event types, and
> then use the same approach of the first example above:
>
> declare EventType
> type : String @key
> end
>
> when
> Event( $type : eventType )
> then
> EventType et = new EventType();
> et.setType( $type );
> logicalInsert( et );
> end
>
> []s
> Edson
>
>
> 2010/3/15 Amit Kumar <amitkumar at gmail.com>
>
>> Hello All,
>>
>>
>> Was doing some rule writing and am seeing some issues which I want to
>> overcome.
>>
>> In Fusion when we send the facts into working memory.. there seems to be
>> no way that rules are automatically getting triggered.
>> We have to call fireAllRules after each fact insertion. Is this the way it
>> was designed. Its like this in the stocktick example also
>>
>> This one should be simple for somebody with little more experience than me
>> In the following rule
>>
>> rule "raise alarm"
>> when
>> Event($type : eventType)
>> $events: ArrayList (size > 10)
>> from collect (Event(eventType == $type))
>> then
>> raise alarm
>>
>> In the above rule the raise alarm is getting called 10 times. .. How can I
>> make it to be called only once.
>>
>> Thanks
>> Amit
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.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/20100315/31a7268a/attachment.html
More information about the rules-users
mailing list