Kewl !.. sounds good. Thanks for your help folks. I will try the options out.<br><br>
<div class="gmail_quote">2010/3/15 Edson Tirelli <span dir="ltr"><<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><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 )
<div class="im"><br> $events: ArrayList (size > 10)<br> from collect (Event(eventType == $type)) <br>then<br></div> // 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
<div class="im"><br> $events: ArrayList (size > 10)<br> from collect (Event(eventType == $type)) <br>then<br></div> // 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">
<div class="im">2010/3/15 Amit Kumar <span dir="ltr"><<a href="mailto:amitkumar@gmail.com" target="_blank">amitkumar@gmail.com</a>></span><br></div>
<blockquote style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hello All,
<div>
<div></div>
<div class="h5"><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></div></div>
<div class="im">_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com/" target="_blank">www.jboss.com</a><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>