Jade Java Agent Communication

。_饼干妹妹 提交于 2019-12-11 06:46:10

问题


I am working on jade for multiple agent platform in my project.

I have a main container and agent container which contains agents.

I want to send data from agent to agent container or main container ..

Since my agent is a client and my main container will be a server .

In the jade architecture i understood that agent container will contain agents.

Is that possible?

I was wondering there are apis to send data among agents.

Thanks in advance


回答1:


I am not sure what it is that you are trying to achieve. Who is the end reciepient of the ACLMessage that you are sending from the JADE agent? is it all the agents that reside in the targeted container?

Just to clarify, a container is essentially an address where agents can reside, it is not an entitiy in of itself that can post and recieve messages. Within the JADE framework, Agents feature an 'Inbox' for ACLMessages, basically a BlockingQueue Object that contains a list of recieved messages. the agent is able to observe its own list and treat them as its lifecycle proceeds. Containers do not feature this ability.

ACLMessages can be directed at specific agents by adding receipients and other details. An Agent that is recieving messages can listen for specific ACLMessages by utilizing a MessageTemplate where you can specifically select messages from the agent's 'inbox' based on match criteria, for example :

Messagetemplate mt = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
ACLMessage msg = myAgent.receive(mt);

will allow the the agent to take the next ACLMessage.INFORM message from its'inbox'.

for further abilities, I suggest you go through the jade API.

Also, for what i believe you are trying to achieve which is send a message to all agents within a container. You can query the AMS agent for a list of agents that is on the platform and then filter them by ContainerID. here is some code to get you started:

AMSAgentDescription[] agents = null;
SearchConstraints sc = new SearchConstraints();
// if multiple searchs are done, isolate them based on the name of searching agent
sc.setSearchId(getAID().getName());
sc.setMaxResults(new Long(-1)); // long value of -1 means get all agents
agents = AMSService.search(this, new AMSAgentDescription(), sc); //Query AMS agent for available agents

This code will retrieve a list of the all the available agents on platform that are registered with the AMS agent. Good luck and post if you have any issues :)



来源:https://stackoverflow.com/questions/38119553/jade-java-agent-communication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!