How about adding a flag to Event to indicate it has been processed?<br>You could then use:<br><br>when<br>&nbsp; Event(processed == false)<br>&nbsp; ...<br><br><br><div class="gmail_quote">On Wed, Dec 10, 2008 at 10:56 AM, techy <span dir="ltr">&lt;<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Thanks all for the reply.<br>
I executed following rules after adding Event fact id ranges from 1 to 8.<br>
Output is given below. counter rule was not executed for distinct event<br>
fact. some help please.<br>
<br>
output :<br>
-----------------------------<br>
adding counter<br>
new count value: 4 , event : 8<br>
new count value: 3 , event : 7<br>
new count value: 2 , event : 8<br>
new count value: 1 , event : 7<br>
-------------------------------<br>
<br>
rule &quot;init&quot;<br>
lock-on-active true<br>
when<br>
 &nbsp; &nbsp; &nbsp; &nbsp;then<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;adding counter&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Counter c = new Counter(4);// init with max count value<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert(c);<br>
<br>
end<br>
<br>
rule &quot;counter&quot;<br>
no-loop true<br>
 &nbsp; &nbsp; &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp;event : Event()<br>
 &nbsp; &nbsp; &nbsp; &nbsp;counter : Counter(count &gt; 0)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;then<br>
 &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;new count value: &quot;+counter.getCount()+&quot; , event :<br>
&quot;+event.getEventId());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;counter.setCount(counter.getCount()-1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;update(counter);<br>
end<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
dave sinclair wrote:<br>
&gt;<br>
&gt; Make counter an object<br>
&gt;<br>
&gt; when<br>
&gt; &nbsp; &nbsp; $counter : Counter(value &lt;= 100)<br>
&gt; ...<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Dec 8, 2008 at 5:05 PM, techy &lt;<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt; I would like to take 100 sampling facts for rule and persist it in the db<br>
&gt;&gt; and ignore other data.<br>
&gt;&gt; How Can I maintain the counter? as global variable? Please clarify with<br>
&gt;&gt; sample code.<br>
&gt;&gt; I tried following way and but it does not work as expected.<br>
&gt;&gt;<br>
&gt;&gt; Ex:<br>
&gt;&gt; global Integer counter;<br>
&gt;&gt; rule &quot;get sampling data&quot;<br>
&gt;&gt; &nbsp; when fact : Foo(some condition) &amp;&amp; eval(counter &lt;= 100)<br>
&gt;&gt; &nbsp; then<br>
&gt;&gt; &nbsp; &nbsp;counter++<br>
&gt;&gt; &nbsp; // do some condition<br>
&gt;&gt; end<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://www.nabble.com/having-counter-in-drl-tp20904469p20904469.html" target="_blank">http://www.nabble.com/having-counter-in-drl-tp20904469p20904469.html</a><br>
&gt;&gt; Sent from the drools - user mailing list archive at Nabble.com.<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div><font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/having-counter-in-drl-tp20904469p20926420.html" target="_blank">http://www.nabble.com/having-counter-in-drl-tp20904469p20926420.html</a><br>
</font><div><div></div><div class="Wj3C7c">Sent from the drools - user mailing list archive at Nabble.com.<br>
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Steven Williams<br><br>Supervising Consultant<br><br>Object Consulting<br>Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501<br><a href="mailto:steven.williams@objectconsulting.com.au">steven.williams@objectconsulting.com.au</a><br>
<a href="http://www.objectconsulting.com.au">www.objectconsulting.com.au</a><br><br>consulting | development | training | support<br>our experience makes the difference<br>