[Aglets-developer] Remote Messagin partiall works but not complete. Suggestions pls ..
Status: Beta
Brought to you by:
cat4hire
|
From: Anil K. <akr...@ya...> - 2005-11-14 04:01:57
|
Hi Luca and ALL ,
The reason why messaging was not working was , i had
a typo which cannot be easily find in the
handleMessage() function . I wrote the name of the
function wrongly as "handleMessgae()" .Thats why
messaging was not working.
Now local messaging and remote messaging is working.
But i have a new problem with remote messaging.
When i send a message from a CreatorAgent to the
SlaveAgent ( which was created in the CreatorAgent
context and dispached to another host) , SlaveAgent
is able to receive the message. But how can i send
a reply message from the SlaveAgent to the parent now
..?
I guess the sendReply() function does not work for
this type of reply messages.
So I tried passing the "parentproxy" as follows while
SlaveAgent being created.
AgletProxy parentProxy =
this.getAgletContext().getAgletProxy(getAgletID());
AgletProxy localProxy = context.createAglet(null,
"fluca.SlaveAgent", parentProxy);
On the SlaveAgent side tw o function s "oncreation()"
and "handleMessgae()"
are coded as follows, to send a reply message to the
CreatorAgent.But it is not working.
public boolean handleMessage(Message msg)
{
if( msg.sameKind("HELLO"))
{
try
{
//Send message to parent
parentProxy.sendMessage(new
Message("RECEIVED"));
System.out.println(" Sent Hello
received Message to Parent. i.e to RMCreatorAgent
");
}catch(Exception e)
{
System.out.println(" RECEIVED reply
Message is not sent .Exception is :"+e);
e.printStackTrace();
}
}
return true;
}
public void onCreation(Object init) {
addMobilityListener(this);
System.out.println(" Called oncreation().");
parentProxy = (AgletProxy)init;
System.out.println(" parentProxy is
:"+parentProxy);
}
On the CreatorAgent side i added the following
handleMessage(Message msg) function to receive the
messages sent fro mSlave Agent.
public boolean handleMessage(Message msg)
{
System.out.println(" Just entered in the
handleMessgae () of CreatorAgent .");
if( msg.sameKind("RECEIVED"))
{
System.out.println("I am CreatorAgent.Reply
Message received from SlaveAgent is :.");
System.out.println(""+msg);
}
return true;
}
Please let me know how to send a reply message from
SlaveAgent to the Creator Agent so that the
communication is complete.
-- Luca Ferrari <cat...@us...>
wrote:
> Anil Kumar's cat, on 16/10/2005 6.51, walking on the
> keyboard wrote:
> > I got a compilation error at one import line
> that
> > syas "import
> com.ibm.aglet.message.MessageException; "
> > .
> > There is no com.ibm.aglet.message directory at
> all .
> > So i just removed this "message" directory and
> used
> > " com.ibm.aglet.MessageException; " and
> compilation
> > was successful .
> >
> > (Note : you may need to correct this error and
> upload
> > it again to CVS.)
>
>
> You're right, I had messed up the CVS, please be
> patiente, I'll fix the
> compilation problems in the CVS repository.
> Coming back to your problem, I've tried the attached
> agents within my
> system and they are working. Since they are similar
> to yours, I think
> the problem is on your systems, but I'm not sure
> what the problem could
> be (note: I used the 2.0.2 version downloaded from
> the web site). For
> the remote messaging, I think there could be a
> problem with a firewall,
> but I don't understand what the local messaging
> problem can be. Could
> you try my agents on your machine please?
> Moreover, try to connect with a telnet client to the
> remote machine on
> the 4434 port (or whatever port you are running the
> remote aglet
> daemon). Finally, what happens if you involve remote
> messaging within
> the same host, that means running two platforms on
> the same host?
>
> Thanks,
> Luca
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
|