Ernest:
Thank you for your reply. The problem I was having was not related to rules
fire asynchronously but rather rules not firing for some data change events.
However I found what was causing it. It had to do with the "Thread sleep
100" on the RHS of the sleep-if-bored rule. See below.
(deffacts idle-fact
(idle))
(defrule sleep-if-bored
(declare (salience -100))
?idle <- (idle)
=>
(retract ?idle)
(call java.lang.Thread sleep 100)
(assert (idle)))
My findings were that if the data change rate in my Java object was faster
that the thread sleep period in the above rule, then some rules did not get
fired on data change event.
I do not quite understand what is this rule doing, but when I commented out
the RHS "Thread sleep 100" function call from the sleep-if-bored rule, rules
started firing for every data change. Can you explain why do I need this
constant firing of the two rules above, and any repercussion on removing the
Thread sleep. (would this eat up CPU resources?)
Write now, I have rete.executeCommand("(run)") executed once in my main
class. Will it be better if rete.executeCommand("(run 1)") was executed once
every time the Java code detects a data change?? (Maybe execute it from
within the methods that change data in my Java objects)
_________
Vicken Kasparian
Cheetah Technologies
941-739-3904 ext. 3550
http://www.cheetahtech.com
> -----Original Message-----
> From: Ernest J. Friedman-Hill [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, December 02, 1999 5:16 PM
> To: Vicken Kasparian
> Cc: [EMAIL PROTECTED]
> Subject: Re: JESS: Rule Firings
>
> Your problem statement is somewhat vague, so I have to guess at the
> details, but I let's say you've got a Bean class "Foo" with one
> property "bar". Then
>
> (defclass foo Foo)
> (definstance foo (new Foo))
>
> Let's say Foo looks like this:
>
> public class Foo extends Thread
> {
> private int bar;
> public Foo() { start(); }
>
> public int getBar() { return bar; }
> public void setBar(int i)
> { /* set property and issue property change event */}
>
> public void run() { int i=0; while (true) setBar(i); }
> }
>
> Then you have a rule like this:
>
> (defrule report-foo-changes
> (foo (bar ?X))
> =>
> (printout t ?X crlf))
>
> Now. The first time setBar() is called, the foo shadow fact is
> modified. "report-foo-changes" is activated. While it is firing, it
> calls "printout." Now, I/O is slow in any language, and there's
> probably time for setBar to be called once or twice while
> report-foo-changes is running. Therefore, before report-foo-changes
> finishes, the foo fact has been modified several times. Each time it
> is modified, the old activation of the rule is cleared, and a new one
> is created. This is how you'd want things to behave: when
> report-foo-changes runs, it reports the value of ?X at the last change
> before the rule started to run.
>
> Anyway, that's probably what's happening. If you want each change to
> be reported synchronously, then do it synchronously - for example, by
> printing somethign in setBar(), or by registering your own
> PropertyChangeListener.
>
>
> I think Vicken Kasparian wrote:
> >
> > Hello:
> >
> > I was doing some tests for a prototype I am working on and found the
> > following situation.
> > I have a rule that writes something to screen every time a data changes.
> > When I create a burst of a high rate data change in a Java object, I am
> not
> > getting a rule fire for each data change. That means some data change
> events
> > are not triggering rules to fire.
> >
> > Is this an expected result or am I doing something wrong??
> >
> > _________
> > Vicken Kasparian
> > Cheetah Technologies
> > 941-739-3904 ext. 3550
> > http://www.cheetahtech.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> > in the BODY of a message to [EMAIL PROTECTED], NOT to the
> > list (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> > ---------------------------------------------------------------------
> >
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Distributed Systems Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> Org. 8920, MS 9012 [EMAIL PROTECTED]
> PO Box 969 http://herzberg.ca.sandia.gov
> Livermore, CA 94550
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> ---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------