<br> Amit, <br><br> 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.<br><br>
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:<br>
<br>when<br> EventType( $type : type )<br> $events: ArrayList (size > 10)<br> from collect
(Event(eventType == $type)) <br>then<br> // do something<br>end<br><br> 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:<br>
<br>when<br> $types : Set() <br> from accumulate( Event($type : eventType),<br> collectSet( $type ) )<br> $type : String() from $types<br> $events: ArrayList (size > 10)<br>
from collect
(Event(eventType == $type)) <br>then<br>
// do something<br>
end<br>
<br> 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:<br><br>declare EventType<br>
type : String @key<br>end<br><br>when<br> Event( $type : eventType )<br>then<br> EventType et = new EventType();<br> et.setType( $type );<br> logicalInsert( et );<br>end<br><br> []s<br> Edson<br> <br>
<br><div class="gmail_quote">2010/3/15 Amit Kumar <span dir="ltr"><<a href="mailto:amitkumar@gmail.com">amitkumar@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello All,<br><br>Was doing some rule writing and am seeing some issues which I want to overcome.<br><br>In Fusion when we send the facts into working memory.. there seems to be no way that rules are automatically getting triggered.<br>
We have to call fireAllRules after each fact insertion. Is this the way it was designed. Its like this in the stocktick example also<br><br>This one should be simple for somebody with little more experience than me<br>In the following rule<br>
<br>rule "raise alarm"<br>when<br> Event($type : eventType)<br> $events: ArrayList (size > 10)<br> from collect (Event(eventType == $type))<br>then<br> raise alarm<br><br>In the above rule the raise alarm is getting called 10 times. .. How can I make it to be called only once.<br>
<br>Thanks<br><font color="#888888">Amit<br>
</font><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>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>