JADE: Problems needing attention in agent communication of remote machine

Source: Internet
Author: User

To realize the communication of agents on different machines in the local area network, two problems need to be paid attention to:

1. The protocol about file and printer sharing within the firewall must be opened to ensure the resolution of the machine name.

2. When the communication aclmessage add receiver when the designated legal aid, this aid must have the full name, the second must have the legal addresses.

Like the following example

import Jade.core.AID;
import jade.domain.AMSService;
Import jade.domain.fipaagentmanagement.*;
public class Sender2 extends Agent {
protected void Setup ()
{

amsagentdescription [] agents = nul L      
Aid rams= New Aid ("Ams@gjpc:1099/jade");//Get AMS on GJPC machine
rams.addaddresses ("Http://gjpc:7778/acc");
      try {
Searchconstraints c = new searchconstraints ();
C.setmaxresults (New Long (-1));
//agents = Amsservice.search (This, new Amsagentdescription (), c);     
//below find Rams inside agents
Agents = Amsservice.search (this, Rams, New Amsagentdescription (), c);
      
catch (Exception e) {
System.out.println ("Problem searching AMS:" + e);
E.printstacktrace ();     
}

Aclmessage msg = new Aclmessage (aclmessage.inform);
Msg.setcontent ("This is the Guojie ' Ping");//local machine name is Guojie
//send messages to them one by one
for (int i=0; I<agents.length;i++) {
if (Agents[i].getname (). Equals (Getaid ())) {
Continue;

System.out.println (Agents[i].getname (). toString ());
Agents[i].getname (). Addaddresses ("Http://gjpc:7778/acc");
//This sentence must have
Msg.addreceiver (Agents[i].getname ());

}

System.out.println ("Wait fro a minute ...");

Send (msg);
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.