Hello Juan,

This all looks basically correct to me. I can think of two things that
might be going wrong:

1) Is 'number_msg' a proper property name (i.e., there's a method
'public int getNumber_message()' in the Mailbox class). Because you're
specifying the property name exactly in the firePropertyChange call,
Jess will only update the fact representing the object if that
particular slot changes. You can make sure Jess is finding the
property simply by executing (facts) after the (definstance) call -
you should see the fact representing the object, with all its slots.

2) Of course, rules will only fire when Jess is running; otherwise,
new messages will create activations, but the activated rule won't
actually fire until a (run).  In agent-like systems, it's common to
use a 'heartbeat rule' to keep the engine running -always-, something
like this:

(defrule sleep-when-idle
  (declare (salience -100))
  (not (sleeping-because-idle))
  =>
  (bind ?id (assert (sleeping-because-idle)))
  (call java.lang.Thread sleep 100)
  (retract ?id))

When a rule like this has been defined, (run) will only return if
(halt) is executed.

I think Juan Luis Mulas Platero wrote:
> 
> 
> Hello jess-users.
> 
>   I am trying to put JESS into an existing agent platform an have 
> the next problem: there is a communications thread listening to a port 
> whose mission is store each message it receives into the mailbox
> of the agent. What I want to do is create a definstance of this mailbox
> inside JESS (that runs in another thread) in order to detect (using a rule 
> with the mailbox in th LHS ofa rule) the arriving of each message. 
> The idea is that the Jess inference engine can access to each message 
> that arrives at the agent so as to make a plan or do some prefix task.
> 
> I have put into the JESS inference engine (using a defglobal)
> a reference to the agent to owns the mailbox object and using the function
> get-member, I have accessed to the mailbox object of the agent. The next
> task is to create a definstance with the reference to the mailbox. Since
> the MailBox object supports PropertyChangeListeners( supports
> addPropertyChangeSuppport(.), ...), each time a message is written to the
> mailbox I call the firePropertyChange(.) method in order to tell JESS that
> the object mailbox has changed and that the rule with the mailbox as a
> pattern in the LHS must be fired. The problem is that such a rule is never fired.
> 
> That's more or less what I have done.
> 
> 1. Put into Jess a reference to the agent who owns the mailbox from JAVA
>    using the Funcall object. I store this reference in a defglobal 
>    variable named ?*AGENT* (this goes well).
>    
> 2. Obtain a reference to the MailBox object of the agent (from JESS) and 
>     create a definstance of this object:
> 
>         (defclass mbox MSM.agent.MailBox)
>         (definstance mbox (get-member ?*AGENT* mailbox))
>         
>     where mailbox is the name of the MailBox object owned by the agent.
>     (It doesn't throw any exception. Seems to go well)
>       
> 3. Create a defrule that must be fired when a changed is reported in the
>    mailbox.
>     
>      (defrule read-message-from-mailbox
>         (mbox (OBJECT ?mbox))
>      =>
>       (do-some-tasks)
>      )
>      
>      BUT this rule is never fired in spite of having used the method
>      pcs.firePropertyChange inside the MailBox object when a message is
>      written to the mailbox.  (pcs is a PropertyChangeSupport object
>      defined inside the MailBox object).
>      
> 4. What I exactly do inside the MailBox object is called the next method 
>    each time a message is written to the mailbox. Each time a message
>    arrives, this method is called but nothing happens:
>      
>    pcs.firePropertyChange("number_msg", new Integer(number_msg), new
>                     Integer(number_msg+1));
>       
>     where number_msg is a variable of the mailbox that counts the number
>     of messages stored at the Mailbox.
>       
>          
>     Could someone help me?
>     Could the problem be related with the fact that I haven't created 
>     the mailbox object inside JESS?(It is impossible to create it inside
>     JESS because it must be created by the agent)
>      
> 
>   Thanks in advanced.
>                               
>                       Juan Luis Mulas Platero.
>                       ETSIT Valladolid
>                       Spain.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (510) 294-2154
Sandia National Labs                FAX:   (510) 294-2234
Org. 8920, MS 9214                  [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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to