How about adding a flag to Event to indicate it has been processed?<br>You could then use:<br><br>when<br> Event(processed == false)<br> ...<br><br><br><div class="gmail_quote">On Wed, Dec 10, 2008 at 10:56 AM, techy <span dir="ltr"><<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>></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 "init"<br>
lock-on-active true<br>
when<br>
then<br>
System.out.println("adding counter");<br>
Counter c = new Counter(4);// init with max count value<br>
insert(c);<br>
<br>
end<br>
<br>
rule "counter"<br>
no-loop true<br>
when<br>
event : Event()<br>
counter : Counter(count > 0)<br>
then<br>
System.out.println("new count value: "+counter.getCount()+" , event :<br>
"+event.getEventId());<br>
counter.setCount(counter.getCount()-1);<br>
update(counter);<br>
end<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
dave sinclair wrote:<br>
><br>
> Make counter an object<br>
><br>
> when<br>
> $counter : Counter(value <= 100)<br>
> ...<br>
><br>
><br>
> On Mon, Dec 8, 2008 at 5:05 PM, techy <<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>> wrote:<br>
><br>
>><br>
>> Hello,<br>
>> I would like to take 100 sampling facts for rule and persist it in the db<br>
>> and ignore other data.<br>
>> How Can I maintain the counter? as global variable? Please clarify with<br>
>> sample code.<br>
>> I tried following way and but it does not work as expected.<br>
>><br>
>> Ex:<br>
>> global Integer counter;<br>
>> rule "get sampling data"<br>
>> when fact : Foo(some condition) && eval(counter <= 100)<br>
>> then<br>
>> counter++<br>
>> // do some condition<br>
>> end<br>
>> --<br>
>> View this message in context:<br>
>> <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>
>> 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>
>><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>
><br>
><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>