RE: [jade-develop] ACLMessage is ALWAYS NULL!! Why ??


Subject: RE: [jade-develop] ACLMessage is ALWAYS NULL!! Why ??
From: Caire Giovanni (Giovanni.Caire@TILAB.COM)
Date: Mon Jan 06 2003 - 11:10:48 MET


Hi,
 
I suspect the code you use to receive a message is
 
ACLMessage msg = myAgent.receive();
 
Please take into account that the receive() method just picks up a message from the agent message queue. If the queue is empty (e.g. because the message you are expecting has not arrived yet) the method returns null.
The correct way to do things is
 
public void action() {
  ACLMessage msg = myAgent.receive();
  if (msg != null) {
    // do something
  }
  else {
    block();
  }
}
 
You can use the Introspector agent to see what messages are waiting in the agent queue.
 
Bye
 
Giovanni
 
-----Original Message-----
From: David [mailto:amdawong@starhub.net.sg]
Sent: marted́ 31 dicembre 2002 23.04
To: JADE
Subject: [jade-develop] ACLMessage is ALWAYS NULL!! Why ??

Hi there,
 
Does anyone know under what circumstances will a message received by an agent be always null ?
 
I tried to send a simple message to an agent using another agent. Agent A and Agent B.
Msg 1 : Agent A sends to Agent B. Mesasge received okay.
Msg 2: Agent B then createReply() back to Agent A. Message received ok too.
Msg 3: Agent A now then tries to send message to Agent B again. => PROBLEM!!
 
 
I have already double check the message outgoing from Agent A to Agent B. Printed it out. It is a proper message, not null message.
But when Agent B receives the Msg 3 sent out from Agent A. It is ALWAYS NULL. Why is it so. Please help.
I have been stuck at this for a very long time. Thanks a lot in advance JAders!!
 
Regards
 

Hi,
 
I suspect the code you use to receive a message is
 
ACLMessage msg = myAgent.receive();
 
Please take into account that the receive() method just picks up a message from the agent message queue. If the queue is empty (e.g. because the message you are expecting has not arrived yet) the method returns null.
The correct way to do things is
 
public void action() {
  ACLMessage msg = myAgent.receive();
  if (msg != null) {
    // do something
  }
  else {
    block();
  }
}
 
You can use the Introspector agent to see what messages are waiting in the agent queue.
 
Bye
 
Giovanni
 
-----Original Message-----
From: David [mailto:amdawong@starhub.net.sg]
Sent: marted́ 31 dicembre 2002 23.04
To: JADE
Subject: [jade-develop] ACLMessage is ALWAYS NULL!! Why ??

Hi there,

 

Does anyone know under what circumstances will a message received by an agent be always null ?

 

I tried to send a simple message to an agent using another agent. Agent A and Agent B.

Msg 1 : Agent A sends to Agent B. Mesasge received okay.

Msg 2: Agent B then createReply() back to Agent A. Message received ok too.

Msg 3: Agent A now then tries to send message to Agent B again. => PROBLEM!!

 

 

I have already double check the message outgoing from Agent A to Agent B. Printed it out. It is a proper message, not null message.

But when Agent B receives the Msg 3 sent out from Agent A. It is ALWAYS NULL. Why is it so. Please help.

I have been stuck at this for a very long time. Thanks a lot in advance JAders!!

 

Regards

 



This archive was generated by hypermail 2a22 : Mon Jan 06 2003 - 11:10:57 MET