I want to send message to an agent from other class that is not an agent. for example Servlet or main static class.
Asked
Active
Viewed 448 times
2
-
have you considered the fact that you are breaking the implementation paradigm? Isn't better to create an agent to send this message? – darlinton Sep 12 '16 at 09:54
-
Thanks for your comment, I can't change servlet class to be an agent. – Ebrahim Amini Sharifi Sep 16 '16 at 03:22
-
1have you tried JadeGateway http://jade.tilab.com/doc/tutorials/JadeGateway.pdf ? – darlinton Sep 21 '16 at 10:42
1 Answers
1
This is an oridnary class not an agent:
MainContainerAgentsRetriever retriever = new MainContainerAgentsRetriever();
JadeGateway.execute(retriever);
// At this point the retriever behaviour has been fully executed --> the list of
// agents running in the Main Container is available: get it and print it
List agents = retriever.getAgents();
if (agents != null) {
System.out.println("Agents living in the Main Container: ");
for (int i = 0; i < agents.size(); ++i) {
System.out.println("- " + ((AID) agents.get(i)).getLocalName());
ACLMessage msg = new ACLMessage();
msg.addReceiver(((AID) agents.get(i)));
msg.setContent("salam refigha");
retriever.send(msg);
}
}

Ebrahim Amini Sharifi
- 984
- 11
- 27